I'm trying to hide/show different columns on a nested rad grid based on a flag in the pre-render event but they are all displaying
These are my grid columns:
and my code in the pre-render
The lines to hide/show the columns is being hit but they are still displaying, is there something else I should be doing?
thanks
These are my grid columns:
<telerik:GridBoundColumn UniqueName="LocalDeanery" ReadOnly="true" DataField="localdeanery" HeaderText="Local Deanery" SortExpression="localdeanery" HtmlEncode="false" ></telerik:GridBoundColumn> <telerik:GridTemplateColumn UniqueName="Sector2013" HeaderText="Sector" SortExpression="hasBeenHeld desc,Sector" AllowFiltering="false" > <ItemTemplate> <asp:Label ID="Label2" runat="server" Text='<%# Eval("Sector").ToString() + " (" + Eval("PrefRank").ToString() + ") " + (Eval("conditional").ToString()==""?"":"Conditional")%>' Visible='<%# Eval("OfferId").ToString()!="" %>' /> </ItemTemplate></telerik:GridTemplateColumn><telerik:GridBoundColumn UniqueName="Region" ReadOnly="true" DataField="tRegion" HeaderText="Region" SortExpression="tRegion" HtmlEncode="false"></telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="Subregion" ReadOnly="true" DataField="tSubRegion" HeaderText="Sub-Region" SortExpression="tSubRegion" HtmlEncode="false" ></telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="Sector2014" ReadOnly="true" DataField="tSector" HeaderText="Sector" SortExpression="tSector" HtmlEncode="false" ></telerik:GridBoundColumn>and my code in the pre-render
protected void RadGrid1_PreRender(object sender, EventArgs e){ RadGrid od = (RadGrid)RadGrid1.MasterTableView.Items[0].ChildItem.FindControl("OfferDataDetail"); Label ry = (Label)RadGrid1.MasterTableView.Items[0].ChildItem.FindControl("LblRoundYear"); int RoundYear = 2014; if (ry != null) RoundYear = int.Parse(ry.Text); //display for 2013 od.Columns.FindByUniqueName("LocalDeanery").Visible = (RoundYear == 2013); od.Columns.FindByUniqueName("Sector2013").Visible = (RoundYear == 2013); //display for 2014 od.Columns.FindByUniqueName("Region").Visible = (RoundYear == 2014); od.Columns.FindByUniqueName("Subregion").Visible = (RoundYear == 2014); od.Columns.FindByUniqueName("Sector2014").Visible = (RoundYear == 2014); od.Rebind();}The lines to hide/show the columns is being hit but they are still displaying, is there something else I should be doing?
thanks