Hi,
I want to show a column in the radgrid detail table depending on a session flag.
I can show the column when I show the detail table, but once I show another detail table for another data item, the column is invisible again.
How do I show the column for all expanded detail table?
Here is my code:
<telerik:RadGrid
ID="radgrid1"
Runat="server"
AutoGenerateColumns="false"
AllowPaging="true"
PageSize="10"
AllowFilteringByColumn="False"
AllowSorting="True"
AllowMultiRowSelection="false"
OnSelectedIndexChanged="radgrid1_SelectedIndexChanged"
OnNeedDataSource="radgrid1_NeedDataSource"
OnUpdateCommand="radgrid1_UpdateCommand"
OnItemCreated="radgrid1_GridItemCreated"
OnItemDataBound ="radgrid1_ItemDataBound"
OnCreateColumnEditor="radgrid1_CreateColumnEditor"
OnItemCommand="radgrid1_ItemCommand"
OnDetailTableDataBind="radgrid1_DetailTableDataBind"
AutoGenerateHierarchy="true"
CellSpacing="0"
GridLines="None"
DataMember="PortalUserTable">
<MasterTableView DataKeyNames= "Id,UserName" EditMode="PopUp" CommandItemDisplay="Top">
<CommandItemSettings ShowExportToExcelButton="true" ShowExportToWordButton="true" ShowExportToPdfButton="true" ShowAddNewRecordButton="false" />
<DetailTables>
<telerik:GridTableView Name="detailtable1"
Width="100%" NoDetailRecordsText="No Location is set up for this user."
AllowFilteringByColumn="false" AllowPaging="false">
<Columns>
<telerik:GridBoundColumn UniqueName="column1" HeaderText="Location" DataField="column1" HeaderStyle-Width="200px" Display="false"/>
DataField="LocationId" Display="false" />
</Columns>
</telerik:GridTableView>
</DetailTables>
<Columns>
.................
</Columns>
<EditFormSettings>
<FormTemplate>
.............................................
</FormTemplate>
</EditFormSettings>
</telerik:RadGrid>
protected void radgrid1_DetailTableDataBind(object source, GridDetailTableDataBindEventArgs e)
{
if (Convert.ToBoolean(Session["flag"]))
{
e.DetailTableView.GetColumn("column1").Display = true;
}
}
I want to show a column in the radgrid detail table depending on a session flag.
I can show the column when I show the detail table, but once I show another detail table for another data item, the column is invisible again.
How do I show the column for all expanded detail table?
Here is my code:
<telerik:RadGrid
ID="radgrid1"
Runat="server"
AutoGenerateColumns="false"
AllowPaging="true"
PageSize="10"
AllowFilteringByColumn="False"
AllowSorting="True"
AllowMultiRowSelection="false"
OnSelectedIndexChanged="radgrid1_SelectedIndexChanged"
OnNeedDataSource="radgrid1_NeedDataSource"
OnUpdateCommand="radgrid1_UpdateCommand"
OnItemCreated="radgrid1_GridItemCreated"
OnItemDataBound ="radgrid1_ItemDataBound"
OnCreateColumnEditor="radgrid1_CreateColumnEditor"
OnItemCommand="radgrid1_ItemCommand"
OnDetailTableDataBind="radgrid1_DetailTableDataBind"
AutoGenerateHierarchy="true"
CellSpacing="0"
GridLines="None"
DataMember="PortalUserTable">
<MasterTableView DataKeyNames= "Id,UserName" EditMode="PopUp" CommandItemDisplay="Top">
<CommandItemSettings ShowExportToExcelButton="true" ShowExportToWordButton="true" ShowExportToPdfButton="true" ShowAddNewRecordButton="false" />
<DetailTables>
<telerik:GridTableView Name="detailtable1"
Width="100%" NoDetailRecordsText="No Location is set up for this user."
AllowFilteringByColumn="false" AllowPaging="false">
<Columns>
<telerik:GridBoundColumn UniqueName="column1" HeaderText="Location" DataField="column1" HeaderStyle-Width="200px" Display="false"/>
DataField="LocationId" Display="false" />
</Columns>
</telerik:GridTableView>
</DetailTables>
<Columns>
.................
</Columns>
<EditFormSettings>
<FormTemplate>
.............................................
</FormTemplate>
</EditFormSettings>
</telerik:RadGrid>
protected void radgrid1_DetailTableDataBind(object source, GridDetailTableDataBindEventArgs e)
{
if (Convert.ToBoolean(Session["flag"]))
{
e.DetailTableView.GetColumn("column1").Display = true;
}
}