I have a hierarchy grid with a GridClientSelectColumn in the child grid & I'm trying to select the boxes that meet user selected criteria on the page. I am able search through the children of the first parent row & select the matching record(s), but after finding the match it loses reference to the parent row & gives me an error stating it "Cannot find a cell bound to column name 'ProjectID'". When I step through the code, I see that the key value of my GridDataItem is no longer pointing to the ID of the parent (ProjectID), but to the child (DataElementID)! While stepping through the code, if I allow things to bypass the error & iterate through a few times, it will eventually return to the key value to the parent & then find the next match. ???
Can someone please explain to me why this is happening?
Here is a snippet of my code...
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
ShowStatusBar
=
"false"
AutoGenerateColumns
=
"False"
PageSize
=
"50"
AllowSorting
=
"True"
AllowMultiRowSelection
=
"true"
AllowPaging
=
"false"
GridLines
=
"none"
OnDetailTableDataBind
=
"RadGrid1_DetailTableDataBind"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
Width
=
"700px"
ClientSettings-Scrolling-AllowScroll
=
"true"
OnPreRender
=
"RadGrid1_PreRender"
ClientSettings-Scrolling-UseStaticHeaders
=
"true"
OnItemDataBound
=
"RadGrid1_ItemDataBound"
>
<
MasterTableView
DataKeyNames
=
"ProjectID"
AllowMultiColumnSorting
=
"false"
HierarchyLoadMode
=
"ServerBind"
>
<
DetailTables
>
<
telerik:GridTableView
DataKeyNames
=
"DataElementID"
Name
=
"DataElementID"
Width
=
"100%"
>
<%-- Child --%>
<
HeaderStyle
Font-Bold
=
"true"
/>
<
Columns
>
<
telerik:GridClientSelectColumn
UniqueName
=
"deSelectColumn"
HeaderStyle-Width
=
"5%"
></
telerik:GridClientSelectColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"first"
HeaderText
=
"1st"
HeaderStyle-Width
=
"5%"
>
<
ItemTemplate
>
<
asp:CheckBox
ID
=
"CheckBox1"
runat
=
"server"
/>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
DataField
=
"DataElementID"
UniqueName
=
"DataElementID"
HeaderText
=
"Data Element ID"
DataType
=
"System.Int16"
HeaderStyle-Width
=
"20%"
Display
=
"true"
/>
<
telerik:GridBoundColumn
DataField
=
"ProjectAreaDescription"
UniqueName
=
"ProjectAreaDescription"
HeaderText
=
"Project Area Description"
DataType
=
"System.String"
HeaderStyle-Width
=
"40%"
/>
<
telerik:GridBoundColumn
DataField
=
"ProjectDataType"
UniqueName
=
"ProjectDataType"
HeaderText
=
"Project Data Type"
DataType
=
"System.String"
HeaderStyle-Width
=
"30%"
/>
</
Columns
>
</
telerik:GridTableView
>
</
DetailTables
>
<%-- Parent --%>
<
HeaderStyle
Font-Bold
=
"true"
/>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"ProjectID"
UniqueName
=
"ProjectID"
HeaderText
=
"Project ID"
DataType
=
"System.Int16"
Groupable
=
"true"
HeaderStyle-Width
=
"20%"
Display
=
"true"
/>
<
telerik:GridBoundColumn
DataField
=
"ProjectNumber"
UniqueName
=
"ProjectNumber"
HeaderText
=
"Project Number"
SortExpression
=
"ProjectNumber"
DataType
=
"System.String"
HeaderStyle-Width
=
"20%"
/>
<
telerik:GridBoundColumn
DataField
=
"ContractNumber"
UniqueName
=
"ContractNumber"
HeaderText
=
"Contract Number"
SortExpression
=
"ContractNumber"
DataType
=
"System.String"
HeaderStyle-Width
=
"20%"
/>
<
telerik:GridBoundColumn
DataField
=
"ProjectName"
UniqueName
=
"ProjectName"
HeaderText
=
"Project Name"
SortExpression
=
"ProjectNumber"
DataType
=
"System.String"
HeaderStyle-Width
=
"40%"
/>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
>
<
Scrolling
AllowScroll
=
"true"
UseStaticHeaders
=
"true"
/>
<
Resizing
AllowColumnResize
=
"false"
/>
<
Selecting
AllowRowSelect
=
"True"
UseClientSelectColumnOnly
=
"true"
/>
</
ClientSettings
>
</
telerik:RadGrid
>
The following code is part of a button click that performs other operations & then performs the selection of the child records that meet the criteria. At the time of selecting the records, I know the value of both the ProjectID (parent) & DataElementID (child). Either way, when I perform the selection I'm running into errors. By the way, currently there are about 700 child records rolled up into about 250 parents.
For
Each
radRow
As
GridDataItem
In
RadGrid1.Items
Dim
strID
As
String
=
Nothing
strID = radRow(
"ProjectID"
).Text
For
i = 0
To
arrProjectID.Count - 1
If
strID = arrProjectID(i).ToString
Then
radRow.Expanded =
True
radRow.ChildItem.NestedTableViews(0).Items(0).Selected =
True
Exit
For
End
If
Next
Next
Thanks, in advance, for your assistance!
Tonya :)