
grand lorie
Top achievements
Rank 1
grand lorie
asked on 23 Mar 2010, 12:41 AM
Hi All
I have a page which has 2 Grid on it (related tables), as follow
Grid1
ItemID Name Address
Grid2
employeeID Photo ItemID
- The Grid 2 has insert new record on it.
What i need is when insert new record on grid2 (depends on the row the user select in grid1) the ItemID get the value automatically from Grid1 and display it as label so the user does not have to enter its value... is it possible?
Thanks
I have a page which has 2 Grid on it (related tables), as follow
Grid1
ItemID Name Address
Grid2
employeeID Photo ItemID
- The Grid 2 has insert new record on it.
What i need is when insert new record on grid2 (depends on the row the user select in grid1) the ItemID get the value automatically from Grid1 and display it as label so the user does not have to enter its value... is it possible?
Thanks
11 Answers, 1 is accepted
0

Shinu
Top achievements
Rank 2
answered on 23 Mar 2010, 09:08 AM
Hi,
You can access the ItemID of selected row in first grid and set that value for ItemID column of Grid2 inside Grid2_ItemDataBound event.
Try the following code inside :
C#:
protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e) |
{ |
if ((e.Item.OwnerTableView.IsItemInserted && e.Item is GridEditFormInsertItem)) |
{ |
if (RadGrid1.SelectedItems.Count > 0) |
{ |
GridDataItem dataItem = (GridDataItem)RadGrid1.SelectedItems[0]; |
string custID = dataItem["ItemID"].Text; |
GridEditFormInsertItem item = (GridEditFormInsertItem)e.Item; |
item["ItemID"].Text = custID; |
} |
} |
} |
-Shinu
0

grand lorie
Top achievements
Rank 1
answered on 23 Mar 2010, 01:08 PM
Thanks Shinu
- I converted the ItemID (grid2) to template then i edited the template by replacing the textbx with label with the ID of ItemId.
- i placed this code on Grid2_ItemDataBound event:
Protected Sub RadGrid2_ItemDataBound(sender As Object, e As GridItemEventArgs)
If (e.Item.OwnerTableView.IsItemInserted AndAlso TypeOf e.Item Is GridEditFormInsertItem) Then
If RadGrid1.SelectedItems.Count > 0 Then
Dim dataItem As GridDataItem = DirectCast(RadGrid1.SelectedItems(0), GridDataItem)
Dim custID As String = dataItem("ItemID").Text
Dim item As GridEditFormInsertItem = DirectCast(e.Item, GridEditFormInsertItem)
item("ItemID").Text = custID
End If
End If
End Sub
but still
- the Label does not show any value on the insert new record form
- when submit insert null into the database.
am i missing something in here?
- I converted the ItemID (grid2) to template then i edited the template by replacing the textbx with label with the ID of ItemId.
- i placed this code on Grid2_ItemDataBound event:
Protected Sub RadGrid2_ItemDataBound(sender As Object, e As GridItemEventArgs)
If (e.Item.OwnerTableView.IsItemInserted AndAlso TypeOf e.Item Is GridEditFormInsertItem) Then
If RadGrid1.SelectedItems.Count > 0 Then
Dim dataItem As GridDataItem = DirectCast(RadGrid1.SelectedItems(0), GridDataItem)
Dim custID As String = dataItem("ItemID").Text
Dim item As GridEditFormInsertItem = DirectCast(e.Item, GridEditFormInsertItem)
item("ItemID").Text = custID
End If
End If
End Sub
but still
- the Label does not show any value on the insert new record form
- when submit insert null into the database.
am i missing something in here?
0

grand lorie
Top achievements
Rank 1
answered on 31 Mar 2010, 11:06 AM
Any Idea???????
0

Shinu
Top achievements
Rank 2
answered on 01 Apr 2010, 11:00 AM
Hello grand,
Controls inside template columns can not be accessed directly using GridColumn name. Try accessing it using FindControl method from GridEditFormInsertItem.Check out the sample code below:
C#:
-Shinu
Controls inside template columns can not be accessed directly using GridColumn name. Try accessing it using FindControl method from GridEditFormInsertItem.Check out the sample code below:
C#:
protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e) |
{ |
if ((e.Item.OwnerTableView.IsItemInserted && e.Item is GridEditFormInsertItem)) |
{ |
if (RadGrid1.SelectedItems.Count > 0) |
{ |
GridDataItem dataItem = (GridDataItem)RadGrid1.SelectedItems[0]; |
string custID = dataItem["ItemID"].Text; |
GridEditFormInsertItem item = (GridEditFormInsertItem)e.Item; |
Label lblItemID = (Label)item.FindControl("lblItemID"); |
lblItemID.Text = custID; |
} |
} |
} |
-Shinu
0

grand lorie
Top achievements
Rank 1
answered on 17 Nov 2010, 12:00 PM
Hi Shinu
I do not know why it is so difficult to get this done, but the code provided did not do any thing.
here is my page code;
and also here is the code behind to get the itemID value from Grid1 to Insert form in Grid2
any idea why?
Thanks
I do not know why it is so difficult to get this done, but the code provided did not do any thing.
here is my page code;
<%@ Page MasterPageFile="~/Master Pages/OrderMasterPage.master" Language="VB" AutoEventWireup="false"
CodeFile="AddOrder.aspx.vb" Inherits="OrderDepartment_AddOrder" %>
<
asp:Content
ID
=
"Content1"
ContentPlaceHolderID
=
"ContentPlaceHolder1"
runat
=
"server"
>
<
table
class
=
"style1"
cellpadding
=
"0"
cellspacing
=
"0"
>
<
style
type
=
"text/css"
>
.viewWrap
{
padding: 15px;
background: #000000 0 0 url(Img/bluegradient.gif) repeat-x;
}
.contactWrap
{
padding: 10px 15px 15px 15px;
background: #fff;
color: #333;
}
.contactWrap td
{
padding: 0 20px 0 0;
}
.contactWrap td td
{
padding: 3px 20px 3px 0;
}
.contactWrap img
{
border: 3px solid #05679d;
}
.style4
{
color: #800000;
font-weight: bold;
}
</
style
>
<!-- end of custom head section -->
<
tr
>
<
td
bgcolor
=
"Black"
class
=
"style3"
>
>> Add Order
</
td
>
</
tr
>
<
td
>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AllowFilteringByColumn
=
"True"
AllowPaging
=
"True"
AllowSorting
=
"True"
DataSourceID
=
"SqlDataSource1"
GridLines
=
"None"
ShowFooter
=
"True"
Skin
=
"Sunset"
>
<
MasterTableView
AutoGenerateColumns
=
"False"
DataKeyNames
=
"ItemID"
DataSourceID
=
"SqlDataSource1"
PageSize
=
"5"
>
<
NestedViewSettings
DataSourceID
=
"SqlDataSource8"
>
<
ParentTableRelation
>
<
telerik:GridRelationFields
DetailKeyField
=
"ItemID"
MasterKeyField
=
"ItemID"
/>
</
ParentTableRelation
>
</
NestedViewSettings
>
<
NestedViewTemplate
>
<
asp:Panel
ID
=
"NestedViewPanel"
runat
=
"server"
CssClass
=
"viewWrap"
>
<
div
class
=
"contactWrap"
>
<
fieldset
style
=
"padding: 10px;"
>
<
legend
style
=
"padding: 5px;"
><
b
>MoreDetails for Item Number: <%#Eval("ItemID")%></
b
>
</
legend
>
<
table
>
<
tr
>
<
td
>
Division:
</
td
>
<
td
>
<
asp:Label
ID
=
"Label1"
Text='<%#Bind("DivisionName") %>' runat="server"></
asp:Label
>
</
td
>
<
td
>
<
asp:Image
ID
=
"Image1"
runat
=
"server"
EnableViewState
=
"true"
TabIndex
=
"0"
ToolTip
=
"This is Photo"
ImageAlign
=
"Right"
Width
=
"60px"
Height
=
"60px"
ImageUrl='<%#Eval("ThumbImage") %>'
Visible="true" />
</
td
>
</
tr
>
<
tr
>
<
td
>
Category:
</
td
>
<
td
>
<
asp:Label
ID
=
"titleLabel"
Text='<%#Bind("CategoryName") %>' runat="server"></
asp:Label
>
</
td
>
</
tr
>
<
tr
>
<
td
>
Item Type:
</
td
>
<
td
>
<
asp:Label
ID
=
"addressLabel"
Text='<%#Bind("TypeName") %>' runat="server"></
asp:Label
>
</
td
>
</
tr
>
<
tr
>
<
td
>
Code:
</
td
>
<
td
>
<
asp:Label
ID
=
"Label2"
Text='<%#Bind("CodeName") %>' runat="server"></
asp:Label
>
</
td
>
</
tr
>
<
tr
>
<
td
>
Full Code:
</
td
>
<
td
>
<
asp:Label
Font-Size
=
"Medium"
ForeColor
=
"Blue"
ID
=
"Label3"
Text='<%#Bind("FullCode") %>'
runat="server"></
asp:Label
>
</
td
>
</
tr
>
<
tr
>
<
td
>
Number of Pages:
</
td
>
<
td
>
<
asp:Label
ID
=
"Label4"
Text='<%#Bind("PagesNumber") %>' runat="server"></
asp:Label
>
</
td
>
</
tr
>
<
tr
>
<
td
>
Release Date:
</
td
>
<
td
>
<
asp:Label
ID
=
"Label5"
Text='<%#Bind("ReleaseDate") %>' runat="server"></
asp:Label
>
</
td
>
</
tr
>
<
tr
>
<
td
>
Discontinued:
</
td
>
<
td
>
<
asp:Label
ID
=
"Label6"
Text='<%#Bind("Discontinued") %>' runat="server"></
asp:Label
>
</
td
>
</
td
>
</
tr
>
<
tr
>
<
tr
>
<
td
>
Item Discription:
</
td
>
<
td
>
<
asp:Label
ID
=
"Label7"
Text='<%#Bind("ItemDescription") %>' runat="server"></
asp:Label
>
</
td
>
</
tr
>
</
table
>
</
fieldset
>
</
div
>
</
asp:Panel
>
</
NestedViewTemplate
>
<
ExpandCollapseColumn
Visible
=
"True"
>
</
ExpandCollapseColumn
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"ItemID"
DataType
=
"System.Int32"
HeaderText
=
"Item ID"
ReadOnly
=
"True"
SortExpression
=
"ItemID"
UniqueName
=
"ItemID"
>
<
HeaderStyle
Width
=
"150px"
/>
<
ItemStyle
Font-Bold
=
"True"
Font-Size
=
"Medium"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"DivisionName"
DataField
=
"DivisionName"
HeaderText
=
"Division"
HeaderStyle-Width
=
"130px"
>
<
FilterTemplate
>
<
telerik:RadComboBox
ID
=
"RadComboBoxDivision"
Width
=
"130"
DataSourceID
=
"SqlDataSource2"
DataTextField
=
"DivisionName"
DataValueField
=
"DivisionName"
Height
=
"100px"
AppendDataBoundItems
=
"true"
SelectedValue='<%# TryCast(Container,GridItem).OwnerTableView.GetColumn("DivisionName").CurrentFilterValue %>'
runat="server" OnClientSelectedIndexChanged="DivisionIndexChanged">
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"All"
/>
</
Items
>
</
telerik:RadComboBox
>
<
telerik:RadScriptBlock
ID
=
"RadScriptBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function DivisionIndexChanged(sender, args) {
var tableView = $find("<%=RadGrid1.MasterTableView.ClientID %>");
tableView.filter("DivisionName", args.get_item().get_value(), "EqualTo");
}
</
script
>
</
telerik:RadScriptBlock
>
</
FilterTemplate
>
<
HeaderStyle
Width
=
"130px"
></
HeaderStyle
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"CategoryName"
DataField
=
"CategoryName"
HeaderText
=
"Category"
HeaderStyle-Width
=
"250px"
>
<
FilterTemplate
>
<
telerik:RadComboBox
ID
=
"RadComboBoxCategory"
Width
=
"250"
DataSourceID
=
"SqlDataSource3"
DataTextField
=
"CategoryName"
DataValueField
=
"CategoryName"
Height
=
"400px"
AppendDataBoundItems
=
"true"
SelectedValue='<%# TryCast(Container,GridItem).OwnerTableView.GetColumn("CategoryName").CurrentFilterValue %>'
runat="server" OnClientSelectedIndexChanged="CategoryIndexChanged" EnableLoadOnDemand="True"
MarkFirstMatch="True">
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"All"
/>
</
Items
>
</
telerik:RadComboBox
>
<
telerik:RadScriptBlock
ID
=
"RadScriptBlock2"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function CategoryIndexChanged(sender, args) {
var tableView = $find("<%# TryCast(Container,GridItem).OwnerTableView.ClientID %>");
tableView.filter("CategoryName", args.get_item().get_value(), "EqualTo");
}
</
script
>
</
telerik:RadScriptBlock
>
</
FilterTemplate
>
<
HeaderStyle
Width
=
"250px"
></
HeaderStyle
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"TypeName"
DataField
=
"TypeName"
HeaderText
=
"Item Type"
HeaderStyle-Width
=
"250px"
>
<
FilterTemplate
>
<
telerik:RadComboBox
ID
=
"RadComboBoxType"
Width
=
"250"
DataSourceID
=
"SqlDataSource4"
DataTextField
=
"TypeName"
DataValueField
=
"TypeName"
Height
=
"400px"
AppendDataBoundItems
=
"true"
SelectedValue='<%# TryCast(Container,GridItem).OwnerTableView.GetColumn("TypeName").CurrentFilterValue %>'
runat="server" OnClientSelectedIndexChanged="TypeIndexChanged" MarkFirstMatch="True">
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"All"
/>
</
Items
>
</
telerik:RadComboBox
>
<
telerik:RadScriptBlock
ID
=
"RadScriptBlock3"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function TypeIndexChanged(sender, args) {
var tableView = $find("<%# TryCast(Container,GridItem).OwnerTableView.ClientID %>");
tableView.filter("TypeName", args.get_item().get_value(), "EqualTo");
}
</
script
>
</
telerik:RadScriptBlock
>
</
FilterTemplate
>
<
HeaderStyle
Width
=
"250px"
></
HeaderStyle
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"FullCode"
HeaderText
=
"Full Code"
SortExpression
=
"FullCode"
UniqueName
=
"FullCode"
HeaderTooltip
=
"enter code then filter to quick item search"
>
<
FooterStyle
Font-Bold
=
"False"
Font-Italic
=
"False"
Font-Overline
=
"False"
Font-Strikeout
=
"False"
Font-Underline
=
"False"
Wrap
=
"False"
/>
<
HeaderStyle
Font-Bold
=
"False"
Font-Italic
=
"False"
Font-Overline
=
"False"
Font-Strikeout
=
"False"
Font-Underline
=
"False"
Wrap
=
"False"
Width
=
"200px"
/>
<
ItemStyle
Font-Bold
=
"False"
Font-Italic
=
"False"
Font-Overline
=
"False"
Font-Strikeout
=
"False"
Font-Underline
=
"False"
Wrap
=
"False"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridCheckBoxColumn
DataField
=
"Discontinued"
DataType
=
"System.Boolean"
HeaderText
=
"Discontinued"
SortExpression
=
"Discontinued"
UniqueName
=
"Discontinued"
>
<
FooterStyle
Font-Bold
=
"False"
Font-Italic
=
"False"
Font-Overline
=
"False"
Font-Strikeout
=
"False"
Font-Underline
=
"False"
Wrap
=
"True"
/>
<
HeaderStyle
Font-Bold
=
"False"
Font-Italic
=
"False"
Font-Overline
=
"False"
Font-Strikeout
=
"False"
Font-Underline
=
"False"
Wrap
=
"True"
Width
=
"60px"
/>
</
telerik:GridCheckBoxColumn
>
<
telerik:GridBoundColumn
DataField
=
"PagesNumber"
DataType
=
"System.Int32"
HeaderText
=
"Number of Pages"
SortExpression
=
"PagesNumber"
UniqueName
=
"PagesNumber"
>
<
HeaderStyle
Width
=
"60px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"CodeName"
HeaderText
=
"Code"
SortExpression
=
"CodeName"
UniqueName
=
"CodeName"
>
<
HeaderStyle
Width
=
"50px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"SectionName"
HeaderText
=
"Section"
SortExpression
=
"SectionName"
UniqueName
=
"SectionName"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"VersionName"
HeaderText
=
"Version"
SortExpression
=
"VersionName"
UniqueName
=
"VersionName"
Visible
=
"False"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"ReleaseDate"
DataType
=
"System.DateTime"
HeaderText
=
"Release Date"
SortExpression
=
"ReleaseDate"
UniqueName
=
"ReleaseDate"
DataFormatString
=
"{0:d}"
Visible
=
"False"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"ItemDescription"
HeaderText
=
"ItemDescription"
SortExpression
=
"ItemDescription"
UniqueName
=
"ItemDescription"
Visible
=
"False"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
EnablePostBackOnRowClick
=
"True"
>
<
Selecting
AllowRowSelect
=
"True"
/>
</
ClientSettings
>
</
telerik:RadGrid
>
</
td
>
<
tr
>
<
td
bgcolor
=
"White"
>
<
span
class
=
"style4"
>You have selected Item Number:</
span
>
<
asp:Label
ID
=
"Label8"
runat
=
"server"
Text
=
""
style
=
"font-weight: 700; color: #000066"
></
asp:Label
>
</
td
>
</
tr
>
<
tr
>
<
td
>
<
telerik:RadGrid
ID
=
"RadGrid2"
runat
=
"server"
AllowAutomaticInserts
=
"True"
AllowAutomaticUpdates
=
"True"
AllowPaging
=
"True"
DataSourceID
=
"SqlDataSource5"
GridLines
=
"None"
Skin
=
"Office2007"
ShowFooter
=
"True"
>
<
MasterTableView
AutoGenerateColumns
=
"False"
CommandItemDisplay
=
"Top"
DataKeyNames
=
"OrderID,Expr1"
DataSourceID
=
"SqlDataSource5"
>
<
RowIndicatorColumn
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
</
RowIndicatorColumn
>
<
ExpandCollapseColumn
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
</
ExpandCollapseColumn
>
<
CommandItemSettings
AddNewRecordText
=
"Add new Order"
/>
<
Columns
>
<
telerik:GridTemplateColumn
DataField
=
"ItemID"
DataType
=
"System.Int32"
DefaultInsertValue
=
""
HeaderText
=
"Item ID"
SortExpression
=
"ItemID"
UniqueName
=
"ItemID"
Visible
=
"False"
>
<
EditItemTemplate
>
<
telerik:RadNumericTextBox
ID
=
"RadNumericTextBox4"
runat
=
"server"
Culture
=
"English (United Kingdom)"
DbValue='<%# Bind("ItemID") %>' ShowSpinButtons="True" Value="0" Width="75px">
<
NumberFormat
DecimalDigits
=
"0"
/>
</
telerik:RadNumericTextBox
>
<
asp:RequiredFieldValidator
ID
=
"RequiredFieldValidator3"
runat
=
"server"
ControlToValidate
=
"RadNumericTextBox4"
ErrorMessage
=
"You must enter Item ID"
Font-Bold
=
"True"
ForeColor
=
"Maroon"
></
asp:RequiredFieldValidator
>
<
asp:Label
ID
=
"lblItemID"
runat
=
"server"
Text
=
"Label"
></
asp:Label
>
</
EditItemTemplate
>
<
ItemTemplate
>
<
asp:Label
ID
=
"ItemIDLabel"
runat
=
"server"
Text='<%# Eval("ItemID") %>' Font-Bold="True"></
asp:Label
>
</
ItemTemplate
>
<
ItemStyle
Font-Bold
=
"True"
Font-Italic
=
"False"
Font-Overline
=
"False"
Font-Size
=
"Small"
Font-Strikeout
=
"False"
Font-Underline
=
"False"
Wrap
=
"True"
/>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
>
<
ItemTemplate
>
<
asp:Button
ID
=
"Button1"
runat
=
"server"
Visible='<%# Eval("OrderSubmit") = False %>'
Text=" Submit order " CommandName="Edit" />
</
ItemTemplate
>
<
HeaderStyle
Width
=
"80px"
/>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
DataField
=
"OrderID"
DataType
=
"System.Int32"
DefaultInsertValue
=
""
HeaderText
=
"Order Number"
ReadOnly
=
"True"
SortExpression
=
"OrderID"
UniqueName
=
"OrderID"
>
<
HeaderStyle
Width
=
"80px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"OrderDate"
DataType
=
"System.DateTime"
HeaderText
=
"Order Date"
SortExpression
=
"OrderDate"
UniqueName
=
"OrderDate"
ReadOnly
=
"True"
>
<
HeaderStyle
Width
=
"150px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
DataField
=
"Quantity"
DataType
=
"System.Int32"
DefaultInsertValue
=
"0"
HeaderText
=
"Quantity"
SortExpression
=
"Quantity"
UniqueName
=
"Quantity"
Aggregate
=
"Sum"
>
<
EditItemTemplate
>
<
telerik:RadNumericTextBox
ID
=
"RadNumericTextBox3"
runat
=
"server"
Culture
=
"English (United Kingdom)"
DbValue='<%# Bind("Quantity") %>' ShowSpinButtons="True" Value="0" Width="100px"
MaxValue="100000" MinValue="0">
<
NumberFormat
DecimalDigits
=
"0"
/>
</
telerik:RadNumericTextBox
>
</
EditItemTemplate
>
<
ItemTemplate
>
<
asp:Label
ID
=
"QuantityLabel"
runat
=
"server"
Text='<%# Eval("Quantity") %>'></
asp:Label
>
</
ItemTemplate
>
<
HeaderStyle
Width
=
"80px"
/>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
DataField
=
"DateRequired"
DataType
=
"System.DateTime"
DefaultInsertValue
=
""
HeaderText
=
"Date Required"
SortExpression
=
"DateRequired"
UniqueName
=
"DateRequired"
>
<
EditItemTemplate
>
<
telerik:RadDatePicker
ID
=
"RadDatePicker2"
runat
=
"server"
Culture
=
"English (United Kingdom)"
DbSelectedDate='<%# Bind("DateRequired") %>' SelectedDate="2010-03-22" Width="200px">
<
Calendar
UseColumnHeadersAsSelectors
=
"False"
runat
=
"server"
UseRowHeadersAsSelectors
=
"False"
ViewSelectorText
=
"x"
>
</
Calendar
>
<
DatePopupButton
HoverImageUrl
=
""
ImageUrl
=
""
/>
<
DateInput
DateFormat
=
"dd/MM/yyyy"
runat
=
"server"
DisplayDateFormat
=
"dd/MM/yyyy"
SelectedDate
=
"2010-03-22"
>
</
DateInput
>
</
telerik:RadDatePicker
>
<
asp:RequiredFieldValidator
ID
=
"RequiredFieldValidator2"
runat
=
"server"
ControlToValidate
=
"RadDatePicker2"
ErrorMessage
=
"Date is required"
Font-Bold
=
"True"
ForeColor
=
"Maroon"
></
asp:RequiredFieldValidator
>
</
EditItemTemplate
>
<
ItemTemplate
>
<
asp:Label
ID
=
"DateRequiredLabel"
runat
=
"server"
Text='<%# Eval("DateRequired", "{0:d}") %>'></
asp:Label
>
</
ItemTemplate
>
<
HeaderStyle
Width
=
"150px"
/>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
DataField
=
"OrderComment"
DefaultInsertValue
=
"No Comment"
HeaderText
=
"Comment"
SortExpression
=
"OrderComment"
UniqueName
=
"OrderComment"
Display
=
"False"
>
<
EditItemTemplate
>
<
telerik:RadTextBox
ID
=
"RadTextBox1"
runat
=
"server"
EmptyMessage
=
"Message to Management"
Height
=
"50px"
Text='<%# Bind("OrderComment") %>' TextMode="MultiLine" Width="250px">
</
telerik:RadTextBox
>
</
EditItemTemplate
>
<
ItemTemplate
>
<
asp:Label
ID
=
"OrderCommentLabel"
runat
=
"server"
Text='<%# Eval("OrderComment") %>'></
asp:Label
>
</
ItemTemplate
>
<
HeaderStyle
VerticalAlign
=
"Top"
/>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
DataField
=
"WarehouseName"
DefaultInsertValue
=
""
HeaderText
=
"Warehouse"
SortExpression
=
"WarehouseName"
UniqueName
=
"WarehouseName"
>
<
EditItemTemplate
>
<
telerik:RadComboBox
ID
=
"RadComboBox7"
runat
=
"server"
DataSourceID
=
"SqlDataSource6"
DataTextField
=
"WarehouseName"
DataValueField
=
"WarehouseID"
SelectedValue='<%# Bind("WarehouseID") %>'
Skin="Sunset">
</
telerik:RadComboBox
>
</
EditItemTemplate
>
<
ItemTemplate
>
<
asp:Label
ID
=
"WarehouseNameLabel"
runat
=
"server"
Text='<%# Eval("WarehouseName") %>'></
asp:Label
>
</
ItemTemplate
>
<
HeaderStyle
Width
=
"150px"
/>
</
telerik:GridTemplateColumn
>
<
telerik:GridCheckBoxColumn
DataField
=
"OrderSubmit"
DataType
=
"System.Boolean"
DefaultInsertValue
=
"True"
HeaderText
=
"Submit"
SortExpression
=
"OrderSubmit"
UniqueName
=
"OrderSubmit"
>
<
HeaderStyle
Width
=
"100px"
/>
</
telerik:GridCheckBoxColumn
>
</
Columns
>
<
EditItemStyle
Font-Bold
=
"True"
Font-Italic
=
"False"
Font-Overline
=
"False"
Font-Size
=
"Small"
Font-Strikeout
=
"False"
Font-Underline
=
"False"
Wrap
=
"True"
/>
<
CommandItemStyle
Font-Bold
=
"False"
/>
</
MasterTableView
>
<
ClientSettings
EnablePostBackOnRowClick
=
"True"
EnableRowHoverStyle
=
"True"
>
</
ClientSettings
>
<
EditItemStyle
Font-Bold
=
"False"
Font-Italic
=
"False"
Font-Overline
=
"False"
Font-Strikeout
=
"False"
Font-Underline
=
"False"
HorizontalAlign
=
"Right"
Wrap
=
"True"
/>
</
telerik:RadGrid
>
</
td
>
</
tr
>
</
table
>
<
div
>
<
asp:ScriptManager
ID
=
"ScriptManager1"
runat
=
"server"
/>
</
div
>
<
asp:SqlDataSource
ID
=
"SqlDataSource1"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:OrderSystemConn %>"
DeleteCommand="DELETE FROM [Item] WHERE [ItemID] = @ItemID" InsertCommand="INSERT INTO [Item] ([DivisionID], [CategoryID], [TypeID], [CodeID], [FullCode], [SectionID], [VersionID], [PagesNumber], [UnitCost], [ReleaseDate], [Discontinued], [ItemDescription]) VALUES (@DivisionID, @CategoryID, @TypeID, @CodeID, @FullCode, @SectionID, @VersionID, @PagesNumber, @UnitCost, @ReleaseDate, @Discontinued, @ItemDescription)"
SelectCommand="SELECT Item.ItemID, Division.DivisionName, Category.CategoryName, Type.TypeName, Code.CodeName, Item.FullCode, Section.SectionName, Version.VersionName, Item.PagesNumber, Item.UnitCost, Item.ItemCost, Item.ReleaseDate, Item.Discontinued, Item.ItemDescription, Item.DivisionID, Item.CategoryID, Item.TypeID, Item.CodeID, Item.SectionID, Item.VersionID FROM Item INNER JOIN Category ON Item.CategoryID = Category.CategoryID INNER JOIN Code ON Item.CodeID = Code.CodeID INNER JOIN Division ON Item.DivisionID = Division.DivisionID INNER JOIN Section ON Item.SectionID = Section.SectionID INNER JOIN Type ON Item.TypeID = Type.TypeID INNER JOIN Version ON Item.VersionID = Version.VersionID ORDER BY Category.CategoryName"
UpdateCommand="UPDATE [Item] SET [DivisionID] = @DivisionID, [CategoryID] = @CategoryID, [TypeID] = @TypeID, [CodeID] = @CodeID, [FullCode] = @FullCode, [SectionID] = @SectionID, [VersionID] = @VersionID, [PagesNumber] = @PagesNumber, [UnitCost] = @UnitCost, [ReleaseDate] = @ReleaseDate, [Discontinued] = @Discontinued, [ItemDescription] = @ItemDescription WHERE [ItemID] = @ItemID">
<
DeleteParameters
>
<
asp:Parameter
Name
=
"ItemID"
/>
</
DeleteParameters
>
<
UpdateParameters
>
<
asp:Parameter
Name
=
"DivisionID"
/>
<
asp:Parameter
Name
=
"CategoryID"
/>
<
asp:Parameter
Name
=
"TypeID"
/>
<
asp:Parameter
Name
=
"CodeID"
/>
<
asp:Parameter
Name
=
"FullCode"
/>
<
asp:Parameter
Name
=
"SectionID"
/>
<
asp:Parameter
Name
=
"VersionID"
/>
<
asp:Parameter
Name
=
"PagesNumber"
/>
<
asp:Parameter
Name
=
"UnitCost"
/>
<
asp:Parameter
Name
=
"ReleaseDate"
/>
<
asp:Parameter
Name
=
"Discontinued"
/>
<
asp:Parameter
Name
=
"ItemDescription"
/>
<
asp:Parameter
Name
=
"ItemID"
/>
</
UpdateParameters
>
<
InsertParameters
>
<
asp:Parameter
Name
=
"DivisionID"
/>
<
asp:Parameter
Name
=
"CategoryID"
/>
<
asp:Parameter
Name
=
"TypeID"
/>
<
asp:Parameter
Name
=
"CodeID"
/>
<
asp:Parameter
Name
=
"FullCode"
/>
<
asp:Parameter
Name
=
"SectionID"
/>
<
asp:Parameter
Name
=
"VersionID"
/>
<
asp:Parameter
Name
=
"PagesNumber"
/>
<
asp:Parameter
Name
=
"UnitCost"
/>
<
asp:Parameter
Name
=
"ReleaseDate"
/>
<
asp:Parameter
Name
=
"Discontinued"
/>
<
asp:Parameter
Name
=
"ItemDescription"
/>
</
InsertParameters
>
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataSource2"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:OrderSystemConn %>"
SelectCommand="SELECT [DivisionID], [DivisionName] FROM [Division] ORDER BY [DivisionID]">
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataSource3"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:OrderSystemConn %>"
SelectCommand="SELECT [CategoryID], [CategoryName] FROM [Category] ORDER BY [CategoryName]">
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataSource4"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:OrderSystemConn %>"
SelectCommand="SELECT [TypeID], [TypeName] FROM [Type] ORDER BY [TypeName]">
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataSource5"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:OrderSystemConn %>"
DeleteCommand="DELETE FROM [Orders] WHERE [OrderID] = @OrderID" InsertCommand="INSERT INTO [Orders] ([Quantity], [DateRequired], [OrderComment], [OrderSubmit], [ItemID], [WarehouseID]) VALUES (@Quantity, @DateRequired, @OrderComment, @OrderSubmit, @ItemID, @WarehouseID)"
SelectCommand="SELECT Orders.OrderID, Orders.OrderDate, Orders.Quantity, Orders.DateRequired, Orders.OrderComment, Orders.OrderSubmit, Orders.ItemID, Warehouse.WarehouseName, Orders.WarehouseID, Warehouse.WarehouseID AS Expr1 FROM Orders INNER JOIN Warehouse ON Orders.WarehouseID = Warehouse.WarehouseID WHERE (Orders.ItemID = @ItemID)"
UpdateCommand="UPDATE [Orders] SET [OrderDate] = GETDATE(), [Quantity] = @Quantity, [DateRequired] = @DateRequired, [OrderComment] = @OrderComment, [OrderSubmit] = @OrderSubmit, [ItemID] = @ItemID, [WarehouseID] = @WarehouseID WHERE [OrderID] = @OrderID">
<
SelectParameters
>
<
asp:ControlParameter
ControlID
=
"RadGrid1"
Name
=
"ItemID"
PropertyName
=
"SelectedValue"
/>
</
SelectParameters
>
<
DeleteParameters
>
<
asp:Parameter
Name
=
"OrderID"
/>
</
DeleteParameters
>
<
UpdateParameters
>
<
asp:Parameter
Name
=
"Quantity"
/>
<
asp:Parameter
Name
=
"DateRequired"
/>
<
asp:Parameter
Name
=
"OrderComment"
/>
<
asp:Parameter
Name
=
"OrderSubmit"
/>
<
asp:Parameter
Name
=
"ItemID"
/>
<
asp:Parameter
Name
=
"WarehouseID"
/>
<
asp:Parameter
Name
=
"OrderID"
/>
</
UpdateParameters
>
<
InsertParameters
>
<
asp:Parameter
Name
=
"Quantity"
/>
<
asp:Parameter
Name
=
"DateRequired"
/>
<
asp:Parameter
Name
=
"OrderComment"
/>
<
asp:Parameter
Name
=
"OrderSubmit"
/>
<
asp:Parameter
Name
=
"ItemID"
/>
<
asp:Parameter
Name
=
"WarehouseID"
/>
</
InsertParameters
>
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataSource7"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:OrderSystemConn %>"
SelectCommand="SELECT Orders.OrderID, Item.FullCode, Orders.OrderDate, Orders.Quantity, Orders.DateRequired, Orders.FinishDate, Status.StatusName, Orders.ItemID, Division.DivisionName, Category.CategoryName, Type.TypeName, Version.VersionName, Code.CodeName, Item.PagesNumber, Item.ReleaseDate, Item.Discontinued, Item.ItemDescription, Item.LargImage, Section.SectionName, Item.ItemID AS Expr1 FROM Orders INNER JOIN Status ON Orders.StatusID = Status.StatusID INNER JOIN Item ON Orders.ItemID = Item.ItemID INNER JOIN Division ON Item.DivisionID = Division.DivisionID INNER JOIN Category ON Item.CategoryID = Category.CategoryID INNER JOIN Code ON Item.CodeID = Code.CodeID INNER JOIN Section ON Item.SectionID = Section.SectionID INNER JOIN Type ON Item.TypeID = Type.TypeID INNER JOIN Version ON Item.VersionID = Version.VersionID WHERE (Orders.ItemID = @ItemID)">
<
SelectParameters
>
<
asp:SessionParameter
Name
=
"ItemID"
SessionField
=
"ItemID"
Type
=
"Int32"
/>
</
SelectParameters
>
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataSource8"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:OrderSystemConn %>"
SelectCommand="SELECT Item.ItemID, Item.DivisionID, Item.CategoryID, Item.TypeID, Item.CodeID, Item.FullCode, Item.SectionID, Item.VersionID, Item.PagesNumber, Item.ReleaseDate, Item.Discontinued, Item.ItemDescription, Item.ItemCost, Item.UnitCost, Item.ImageName, Item.ThumbImage, Item.LargImage, Category.CategoryName, Version.VersionName, Code.CodeName, Division.DivisionName, Section.SectionName, Type.TypeName FROM Item INNER JOIN Category ON Item.CategoryID = Category.CategoryID INNER JOIN Code ON Item.CodeID = Code.CodeID INNER JOIN Division ON Item.DivisionID = Division.DivisionID INNER JOIN Section ON Item.SectionID = Section.SectionID INNER JOIN Type ON Item.TypeID = Type.TypeID INNER JOIN Version ON Item.VersionID = Version.VersionID WHERE (Item.ItemID = @ItemID)">
<
SelectParameters
>
<
asp:SessionParameter
Name
=
"ItemID"
SessionField
=
"ItemID"
Type
=
"Int32"
/>
</
SelectParameters
>
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataSource6"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:OrderSystemConn %>"
SelectCommand="SELECT [WarehouseID], [WarehouseName] FROM [Warehouse] ORDER BY [WarehouseName]">
</
asp:SqlDataSource
>
</
asp:Content
>
<
asp:Content
ID
=
"Content2"
runat
=
"server"
ContentPlaceHolderID
=
"head"
>
<
style
type
=
"text/css"
>
.style3
{
text-align: center;
color: #FFFFFF;
font-size: x-large;
}
</
style
>
</
asp:Content
>
Protected Sub RadGrid2_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs)
If (e.Item.OwnerTableView.IsItemInserted AndAlso TypeOf e.Item Is GridEditFormInsertItem) Then
If RadGrid1.SelectedItems.Count > 0 Then
Dim dataItem As GridDataItem = DirectCast(RadGrid1.SelectedItems(0), GridDataItem)
Dim custID As String = dataItem("ItemID").Text
Dim item As GridEditFormInsertItem = DirectCast(e.Item, GridEditFormInsertItem)
Dim lblItemID As Label = DirectCast(item.FindControl("lblItemID"), Label)
lblItemID.Text = custID
End If
End If
End Sub
any idea why?
Thanks
0

grand lorie
Top achievements
Rank 1
answered on 22 Nov 2010, 04:35 PM
any hope????????????????????
0

Shinu
Top achievements
Rank 2
answered on 23 Nov 2010, 11:53 AM
Hello,
To my regret, I am not quite sure about the issue that you are facing, since the code looks very good and working fine. Can someone from Telerik give us a hand?
By the by, have you attached the ItemDataBound event to RadGrid2?
-Shinu.
To my regret, I am not quite sure about the issue that you are facing, since the code looks very good and working fine. Can someone from Telerik give us a hand?
By the by, have you attached the ItemDataBound event to RadGrid2?
-Shinu.
0

grand lorie
Top achievements
Rank 1
answered on 26 Nov 2010, 11:07 PM
Shinu
Thanks for your reply, and yes the code is working fine except the issue i am seeking a solution for.
hope that someone from Telerik will help us on that..
hopefully..
Lorie
Thanks for your reply, and yes the code is working fine except the issue i am seeking a solution for.
hope that someone from Telerik will help us on that..
hopefully..
Lorie
0
Hi grand,
I observed that for the second grid you are using automatic inserts. In this case, for the ItemID to be inserted in the database, you need to handle the Insert event of the DataSource control and there set the DefaultValue for the ItemID parameter to the ItemID of the selected item in the first grid.
Try it out and let me know if this works for you.
Kind regards,
Iana
the Telerik team
I observed that for the second grid you are using automatic inserts. In this case, for the ItemID to be inserted in the database, you need to handle the Insert event of the DataSource control and there set the DefaultValue for the ItemID parameter to the ItemID of the selected item in the first grid.
Try it out and let me know if this works for you.
Kind regards,
Iana
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0

grand lorie
Top achievements
Rank 1
answered on 01 Dec 2010, 05:46 PM
Hi Iana
and thanks for your reply, but this did not work either, plus the second grid does not have automatic insert.
The page is working like the following:.
Grid 1 and grid 2, when the user selects any row on grid 1 the page refresh and the grid 2 appears at the bottom of the page with insert new record on top of it (grid2), the form for inserting into grid 2 has a field call "ItemID" ---which is primary key for grid 1 ----- so i need this to be inserted automatically into the form of Grid 2 so the user does not have to enter it, and if the user click another row this will change as well.
any idea???
and thanks for your reply, but this did not work either, plus the second grid does not have automatic insert.
The page is working like the following:.
Grid 1 and grid 2, when the user selects any row on grid 1 the page refresh and the grid 2 appears at the bottom of the page with insert new record on top of it (grid2), the form for inserting into grid 2 has a field call "ItemID" ---which is primary key for grid 1 ----- so i need this to be inserted automatically into the form of Grid 2 so the user does not have to enter it, and if the user click another row this will change as well.
any idea???
0
Hi grand,
From the provided information I assume that on selection of the first grid you are putting the second grid in insert mode. In this case you can handle the ItemCommand event of the second grid and set predefined values for the insert fields as shown in this help article (Setting predefined values for different column editors section)
Regards,
Iana
the Telerik team
From the provided information I assume that on selection of the first grid you are putting the second grid in insert mode. In this case you can handle the ItemCommand event of the second grid and set predefined values for the insert fields as shown in this help article (Setting predefined values for different column editors section)
Regards,
Iana
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.