Hello Telerik,
I build the grid columns and set up the relationships in aspx and the data source is set in code-behind. The gird changes depending on a node selection which sends in a ID to filter out the master grid, which in turn filters out the detail grid based off the relationship.
Here is the grid in aspx:
Now in code behind i change the data with the node being selected in a TreeView on the page.
This code works fine for filling in the master table with the appropriate records. Now when a record is expanded by clicking its arrow - showing the detail grid it is always nothing.
This is the data source for the detail - setup in the page load.
I also tried to put it in the Handles RadGridMemberBoardPosition.DetailTableDataBind event, but it still failed to show the records related to the master table. This is a little different than your example http://demos.telerik.com/aspnet-ajax/grid/examples/programming/hierarchy/defaultvb.aspx so I was wondering if it should all be in the code-behind. Also, if this will work in my scenario with a node changing the data source of a master and detail tables at run-time.
Can you shed some light on this?
Thanks!
SDI
I build the grid columns and set up the relationships in aspx and the data source is set in code-behind. The gird changes depending on a node selection which sends in a ID to filter out the master grid, which in turn filters out the detail grid based off the relationship.
Here is the grid in aspx:
<
telerik:RadGrid
runat
=
"server"
ID
=
"RadGridMemberBoardPosition"
Width
=
"350px"
Height
=
"460px"
AutoGenerateColumns
=
"false"
>
<
MasterTableView
DataKeyNames
=
"MemberId"
>
<
Columns
>
<
telerik:GridClientSelectColumn
ItemStyle-Width
=
"10%"
/>
<
telerik:GridBoundColumn
DataField
=
"Name"
DataType
=
"System.String"
HeaderText
=
"Name"
UniqueName
=
"Name"
/>
</
Columns
>
<
DetailTables
>
<
telerik:GridTableView
DataKeyNames
=
"MemberId"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"FullName"
DataType
=
"System.String"
HeaderText
=
"FullName"
UniqueName
=
"FullName"
/>
<
telerik:GridBoundColumn
DataField
=
"EmailAddress"
DataType
=
"System.String"
HeaderText
=
"EmailAddress"
UniqueName
=
"EmailAddress"
/>
</
Columns
>
</
telerik:GridTableView
>
</
DetailTables
>
<
ParentTableRelation
>
<
telerik:GridRelationFields
DetailKeyField
=
"MemberId"
MasterKeyField
=
"MemberId"
/>
</
ParentTableRelation
>
</
MasterTableView
>
<
ClientSettings
Selecting-AllowRowSelect
=
"true"
Scrolling-AllowScroll
=
"true"
/>
</
telerik:RadGrid
>
Now in code behind i change the data with the node being selected in a TreeView on the page.
Protected Sub RadTreeViewGroups_NodeClick(sender As Object, e As Telerik.Web.UI.RadTreeNodeEventArgs) Handles RadTreeViewGroups.NodeClick
If Me.m_cMyManager Is Nothing Then
Me.m_cMyManager = New cMyManager
End If
' get the board positions and the members for those postions - hierarchical grid
Me.RadGridMemberBoardPosition.DataSource = Me.GetGroupBoardPositionDT(Me.m_cMyManager, e.Node.Attributes("GroupId"))
Me.RadGridMemberBoardPosition.Rebind()
End Sub
This code works fine for filling in the master table with the appropriate records. Now when a record is expanded by clicking its arrow - showing the detail grid it is always nothing.
This is the data source for the detail - setup in the page load.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Me.m_cMyManager Is Nothing Then
Me.m_cMyManager = New cMyManager
End If
' get the sql datasource for the detail of the datagrid
Dim mySqlDataSource As New SqlDataSource("System.Data.SqlClient", Me.m_cMyManager.MyDb.ConnectionString(), Me.GetBoardPositionMembersQuery(Me.m_cMyManager))
' add the parameters
Dim myParameter As New UI.WebControls.Parameter("MemberId", DbType.Int64)
mySqlDataSource.SelectParameters.Add(myParameter)
Me.RadGridMemberBoardPosition.MasterTableView.DetailTables(0).DataSource = mySqlDataSource
End Sub
I also tried to put it in the Handles RadGridMemberBoardPosition.DetailTableDataBind event, but it still failed to show the records related to the master table. This is a little different than your example http://demos.telerik.com/aspnet-ajax/grid/examples/programming/hierarchy/defaultvb.aspx so I was wondering if it should all be in the code-behind. Also, if this will work in my scenario with a node changing the data source of a master and detail tables at run-time.
Can you shed some light on this?
Thanks!
SDI