I m trying to Bind DetailTable as per your demo example but unable to do that.
DetailTable is Expanding but does not show any data while datasource is available.
protected void RadGrid_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
if (!e.IsFromDetailTable)
{
try
{
DemomailViewings.DataSource = ViewingHelperX.GetViewingsForCurrentUser(UserID, DateStart, DateEnd, Session_ID);
}
catch (Exception ex)
{
// log error
}
}
}
public void RadGrid_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
{
try
{
if (e.DetailTableView.Name == "GroupViewing")
{
GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;
int ContactID = Convert.ToInt32(dataItem.GetDataKeyValue("ContactID"));
e.DetailTableView.DataSource = ContactHelper.GetContacts(ContactID);
}
}
catch (Exception ex)
{
// log error
}
}
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadGrid">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid"></telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadGrid ID="RadGrid" runat="server" Width="95%" ShowHeadersWhenNoRecords="true"
ShowStatusBar="true" AutoGenerateColumns="False"
PageSize="50" AllowSorting="True" AllowMultiRowSelection="False" AllowPaging="True"
OnDetailTableDataBind="RadGrid_DetailTableDataBind" OnNeedDataSource="RadGrid_NeedDataSource">
<PagerStyle Mode="NumericPages"></PagerStyle>
<MasterTableView Width="100%" DataKeyNames="ContactID" AllowSorting="True" HierarchyLoadMode="ServerOnDemand">
<DetailTables>
<telerik:GridTableView AutoGenerateColumns="false" runat="server" Name="GroupViewing" DataKeyNames="Id" AllowFilteringByColumn="false"
AllowSorting="false">
<ParentTableRelation>
<telerik:GridRelationFields DetailKeyField="Id" MasterKeyField="ContactID" />
</ParentTableRelation>
<PagerStyle Visible="false" />
<Columns>
<telerik:GridBoundColumn DataField="FirstName" HeaderText="First Name" />
<telerik:GridBoundColumn DataField="AccountId" HeaderText="Company Name" />
<telerik:GridBoundColumn DataField="Title" HeaderText="Title" />
<telerik:GridBoundColumn DataField="Phone" HeaderText="Phone" />
</Columns>
</telerik:GridTableView>
</DetailTables>
<Columns>
<telerik:GridTemplateColumn SortExpression="InGroup" HeaderText="Group Viewing">
<ItemTemplate>
<asp:Image ID="grpImage" runat="server" />
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn ShowSortIcon="true" SortExpression="FirstName" DataField="FirstName"
HeaderText="FirstName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn ShowSortIcon="true" SortExpression="LastName" DataField="LastName"
HeaderText="LastName">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn SortExpression="email" UniqueName="Email" HeaderText="Email">
<ItemTemplate>
<a id="contactLink" style="cursor: pointer" runat="server"></a>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn ShowSortIcon="true" SortExpression="Title" AllowSorting="true"
DataField="Title" HeaderText="Title">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Phone" SortExpression="Phone" AllowSorting="true"
HeaderText="Phone">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn ShowSortIcon="true" SortExpression="CompanyName" AllowSorting="true"
DataField="CompanyName" HeaderText="CompanyName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn ShowSortIcon="true" AllowSorting="true" DataField="SessionTitle"
SortExpression="title" HeaderText="Video Viewed">
</telerik:GridBoundColumn>
<telerik:GridDateTimeColumn ShowSortIcon="true" AllowSorting="true" SortExpression="SentDate"
DataFormatString="{0:MM/dd/yyyy}" DataField="SentDate" HeaderText="Sent Date">
</telerik:GridDateTimeColumn>
<telerik:GridDateTimeColumn ShowSortIcon="true" AllowSorting="true" SortExpression="ViewedDate"
DataFormatString="{0:MM/dd/yyyy}" DataField="ViewedDate" HeaderText="ViewedDate">
</telerik:GridDateTimeColumn>
<telerik:GridBoundColumn ShowSortIcon="true" AllowSorting="true" DataField="DurationText"
SortExpression="Duration" HeaderText="Duration">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn ShowSortIcon="true" AllowSorting="true" SortExpression="location"
DataField="location" HeaderText="Location">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
DetailTable is Expanding but does not show any data while datasource is available.
protected void RadGrid_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
if (!e.IsFromDetailTable)
{
try
{
DemomailViewings.DataSource = ViewingHelperX.GetViewingsForCurrentUser(UserID, DateStart, DateEnd, Session_ID);
}
catch (Exception ex)
{
// log error
}
}
}
public void RadGrid_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
{
try
{
if (e.DetailTableView.Name == "GroupViewing")
{
GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;
int ContactID = Convert.ToInt32(dataItem.GetDataKeyValue("ContactID"));
e.DetailTableView.DataSource = ContactHelper.GetContacts(ContactID);
}
}
catch (Exception ex)
{
// log error
}
}
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadGrid">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid"></telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadGrid ID="RadGrid" runat="server" Width="95%" ShowHeadersWhenNoRecords="true"
ShowStatusBar="true" AutoGenerateColumns="False"
PageSize="50" AllowSorting="True" AllowMultiRowSelection="False" AllowPaging="True"
OnDetailTableDataBind="RadGrid_DetailTableDataBind" OnNeedDataSource="RadGrid_NeedDataSource">
<PagerStyle Mode="NumericPages"></PagerStyle>
<MasterTableView Width="100%" DataKeyNames="ContactID" AllowSorting="True" HierarchyLoadMode="ServerOnDemand">
<DetailTables>
<telerik:GridTableView AutoGenerateColumns="false" runat="server" Name="GroupViewing" DataKeyNames="Id" AllowFilteringByColumn="false"
AllowSorting="false">
<ParentTableRelation>
<telerik:GridRelationFields DetailKeyField="Id" MasterKeyField="ContactID" />
</ParentTableRelation>
<PagerStyle Visible="false" />
<Columns>
<telerik:GridBoundColumn DataField="FirstName" HeaderText="First Name" />
<telerik:GridBoundColumn DataField="AccountId" HeaderText="Company Name" />
<telerik:GridBoundColumn DataField="Title" HeaderText="Title" />
<telerik:GridBoundColumn DataField="Phone" HeaderText="Phone" />
</Columns>
</telerik:GridTableView>
</DetailTables>
<Columns>
<telerik:GridTemplateColumn SortExpression="InGroup" HeaderText="Group Viewing">
<ItemTemplate>
<asp:Image ID="grpImage" runat="server" />
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn ShowSortIcon="true" SortExpression="FirstName" DataField="FirstName"
HeaderText="FirstName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn ShowSortIcon="true" SortExpression="LastName" DataField="LastName"
HeaderText="LastName">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn SortExpression="email" UniqueName="Email" HeaderText="Email">
<ItemTemplate>
<a id="contactLink" style="cursor: pointer" runat="server"></a>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn ShowSortIcon="true" SortExpression="Title" AllowSorting="true"
DataField="Title" HeaderText="Title">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Phone" SortExpression="Phone" AllowSorting="true"
HeaderText="Phone">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn ShowSortIcon="true" SortExpression="CompanyName" AllowSorting="true"
DataField="CompanyName" HeaderText="CompanyName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn ShowSortIcon="true" AllowSorting="true" DataField="SessionTitle"
SortExpression="title" HeaderText="Video Viewed">
</telerik:GridBoundColumn>
<telerik:GridDateTimeColumn ShowSortIcon="true" AllowSorting="true" SortExpression="SentDate"
DataFormatString="{0:MM/dd/yyyy}" DataField="SentDate" HeaderText="Sent Date">
</telerik:GridDateTimeColumn>
<telerik:GridDateTimeColumn ShowSortIcon="true" AllowSorting="true" SortExpression="ViewedDate"
DataFormatString="{0:MM/dd/yyyy}" DataField="ViewedDate" HeaderText="ViewedDate">
</telerik:GridDateTimeColumn>
<telerik:GridBoundColumn ShowSortIcon="true" AllowSorting="true" DataField="DurationText"
SortExpression="Duration" HeaderText="Duration">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn ShowSortIcon="true" AllowSorting="true" SortExpression="location"
DataField="location" HeaderText="Location">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>