I basically have a RadGrid and inside the RadGrid is a DetailTable. Now the DetailTable does not expand, but when I debug the DetailTableDataBind event I see that there is data assigned to the DataSource. If I comment out everything in the DetailTableDataBind then the DetailTable expands but obviously wont have any row data since I had commented out the event. Basically I want the DetailTable to show a column that was used inside the RadGrid, which in this case is the “Comment” column.
Why when I try and assign a DataSource that the DetailTable wont expand?
Here are some snippets of code.
The aspx page
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="MemberCommentsGrid">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="MemberCommentsGrid" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadGrid ID="MemberCommentsGrid" runat="server" AutoGenerateColumns="false"
AllowPaging="true" PageSize="20" ShowStatusBar="true" OnDetailTableDataBind="MemberCommentsGrid_DetailTableDataBind" Skin="WebBlue">
<ClientSettings AllowExpandCollapse="true">
</ClientSettings>
<MasterTableView AllowMultiColumnSorting="true" DataKeyNames="MemberCommentID">
<Columns>
<telerik:GridBoundColumn DataField="MemberCommentID" HeaderText="Comment ID">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Comment" HeaderText="Comment Text">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="DateAdded" HeaderText="Date Added">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="UserID" HeaderText="Comment Created By">
</telerik:GridBoundColumn>
</Columns>
<DetailTables>
<telerik:GridTableView Name="MemberCommentsGrid" DataKeyNames="MemberCommentID" runat="server" AutoGenerateColumns="false">
<Columns>
<telerik:GridBoundColumn DataField="Comment" HeaderText="Full ID">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Comment" HeaderText="Full Comment">
</telerik:GridBoundColumn>
</Columns>
</telerik:GridTableView>
</DetailTables>
</MasterTableView>
</telerik:RadGrid>
The cs page
protected void Page_Load(object sender, EventArgs e)
{
#region Getting DataTable data
string memberName = string.Empty;
if (!IsPostBack)
{
if (Request.QueryString["MemName"] != null)
memberName = Request.QueryString["MemName"].ToString();
else
Response.Redirect("../Account/Login.aspx");
using (AcquirerPortal.Data.MemberComments mc = new AcquirerPortal.Data.MemberComments())
{
dtMemberComments = mc.GetMemberComments(Members.GetMemberIDByMemberName(memberName));
}
}
#endregion
MemberCommentsGrid.DataSource = dtMemberComments;
MemberCommentsGrid.DataBind();
}
protected void MemberCommentsGrid_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
{
e.DetailTableView.DataSource = e.DetailTableView.ParentItem["Comment"].Text;
}
If there is a better way of doing this, please let me know.
Perhaps the comment field needs to be cast to a list first?