Hello group,
I'am trying to add a gridview to a radgrid detailtable from code behind. De radgrid is databound from the code behind with datatables. Now i want to add a gridview on the ItemDataBound event of the radgrid. I have the following snippet aspx:
<
telerik:GridTableView
Name
=
"Sales"
AutoGenerateColumns
=
"false"
Width
=
"100%"
DataKeyNames
=
"DetailCode,DetailSubCode"
ShowHeadersWhenNoRecords
=
"false"
HierarchyDefaultExpanded
=
"true"
HierarchyLoadMode
=
"ServerOnDemand"
>
<
DetailTables
>
<
telerik:GridTableView
Name
=
"Planning"
>
<
ItemTemplate
>
<
asp:GridView
ID
=
"GridView1"
runat
=
"server"
>
</
asp:GridView
>
</
ItemTemplate
>
</
telerik:GridTableView
>
<
telerik:GridTableView
AutoGenerateColumns
=
"false"
DataKeyNames
=
"ProdHeaderDossierCode"
HierarchyDefaultExpanded
=
"false"
Name
=
"ProdDossier"
>
<
ParentTableRelation
>
<
telerik:GridRelationFields
DetailKeyField
=
"DetailCode"
MasterKeyField
=
"DetailCode"
/>
<
telerik:GridRelationFields
DetailKeyField
=
"DetailSubCode"
MasterKeyField
=
"DetailSubCode"
/>
</
ParentTableRelation
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"ProdHeaderDossierCode"
HeaderText
=
"ProdDossier"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"ProdStatusCode"
HeaderText
=
"St."
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"StartDate"
HeaderText
=
"Start"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"EndDate"
HeaderText
=
"Eind"
>
</
telerik:GridBoundColumn
>
</
Columns
>
<
NoRecordsTemplate
>
<
div
style
=
"text-align: center;"
>
Geen gegevens</
div
>
</
NoRecordsTemplate
>
<
DetailTables
>
<
telerik:GridTableView
Name
=
"Oper"
AutoGenerateColumns
=
"false"
Width
=
"100%"
DataKeyNames
=
"ProdHeaderDossierCode"
ShowHeadersWhenNoRecords
=
"false"
HierarchyDefaultExpanded
=
"false"
HierarchyLoadMode
=
"ServerOnDemand"
>
<
ParentTableRelation
>
<
telerik:GridRelationFields
DetailKeyField
=
"ProdHeaderDossierCode"
MasterKeyField
=
"ProdHeaderDossierCode"
/>
</
ParentTableRelation
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"MachGrpCode"
HeaderText
=
"Bew."
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"ProdBooStatusCode"
HeaderText
=
"St."
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"MachPlanTime"
HeaderText
=
"Bew.PT"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"StartDate"
HeaderText
=
"Start"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"EndDate"
HeaderText
=
"Eind"
>
</
telerik:GridBoundColumn
>
<
telerik:GridCheckBoxColumn
DataField
=
"OperStartedInd"
HeaderText
=
"Gestart"
ItemStyle-HorizontalAlign
=
"Center"
>
</
telerik:GridCheckBoxColumn
>
<
telerik:GridCheckBoxColumn
DataField
=
"OperFinishedInd"
HeaderText
=
"Gereed"
ItemStyle-HorizontalAlign
=
"Center"
>
</
telerik:GridCheckBoxColumn
>
</
Columns
>
<
NoRecordsTemplate
>
<
div
style
=
"text-align: center;"
>
Geen gegevens</
div
>
</
NoRecordsTemplate
>
</
telerik:GridTableView
>
</
DetailTables
>
</
telerik:GridTableView
>
</
DetailTables
>
And the code for ItemDataBound:
Protected Sub RgNav_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RgNav.ItemDataBound
If e.Item.ItemType = GridItemType.Item Then
If e.Item.OwnerTableView.Name = "Sales" Then
Dim DetailCode As String = e.Item.Cells(2).Text
Dim DetailSubCode As String = e.Item.Cells(3).Text
For Each Table As GridTableView In e.Item.OwnerTableView.DetailTables
If Table.Name = "Planning" Then
Dim Gv As GridView = Table.FindControl("GridView1")
Gv.DataSource = "Something"
Table.Controls.Add(Gv)
End If
Next
End If
End If
End Sub
Any help is welcome.
Thanks in advance,
René