I am testing a RadGrid that uses multiple GridTemplateColumns because I need a multi-line header so inside of each GridTemplateColumn I have HeaderTemplate and an ItemTemplate to define cells with a table for display. This works as required. In my test case I have 6 gridtemplatecolumns that make up one RadGrid. Now I want to test how to make one of these six gridtemplatecolumns Not Visible at PreRender. I have tried this in the declarative (as part of the GridTemplateColumn I set this to Visible=False) and the column is not displayed, just as I want. However, I cannot figure out how to accomplish the same in code behind.
Let's say I have:
GridTemplateColumn UniqueName="GTC1"
HeaderTemplate
ItemTemplate
GridTemplateColumn UniqueName="GTC2"
HeaderTemplate
ItemTemplate
GridTemplateColumn UniqueName="GTC3"
HeaderTemplate
ItemTemplate
Now I want to make "GTC2" Not Visible in code behind. How do I perform a findcontrol on "GTC2" in PreRender event? If I can find "GTC2" then I can set Visible=False. I think I want to perform this findcontrol in PreRender or do I need to access the GridTemplateColumn in a different event to make this work?
I tried this in PreRender:
This gives the message "Type System.Web.Ui.Control cannot be converted to Telerik.Web.Ui.GridTemplateColumn." Maybe I cannot access the GridTemplateColumn in code behind? If not, how might I access the tables that are defined inside of the HeaderTemplate and ItemTemplate?
Thanks in advance for any help you can provide...Dan
Let's say I have:
GridTemplateColumn UniqueName="GTC1"
HeaderTemplate
ItemTemplate
GridTemplateColumn UniqueName="GTC2"
HeaderTemplate
ItemTemplate
GridTemplateColumn UniqueName="GTC3"
HeaderTemplate
ItemTemplate
Now I want to make "GTC2" Not Visible in code behind. How do I perform a findcontrol on "GTC2" in PreRender event? If I can find "GTC2" then I can set Visible=False. I think I want to perform this findcontrol in PreRender or do I need to access the GridTemplateColumn in a different event to make this work?
I tried this in PreRender:
Dim gtc As GridTemplateColumn = TryCast(RadGrid1.FindControl("GTC2"), GridTemplateColumn)
gtc.Visible =
False
This gives the message "Type System.Web.Ui.Control cannot be converted to Telerik.Web.Ui.GridTemplateColumn." Maybe I cannot access the GridTemplateColumn in code behind? If not, how might I access the tables that are defined inside of the HeaderTemplate and ItemTemplate?
Thanks in advance for any help you can provide...Dan