Hi all
I has trying to addColumns Dinamycally to a RadGrid
Here is the Code Snippet
I create a custom Header and ItemTemplate to the GridTemplateColumn
The Problem is when there are a PostBack on Page the TemplateColumns are cleared (lost their header values as Item values), but bound columns mantain theirs values and Headers.
I'm using NeedDataSource Event to Bound The Grid Also.
I Have already read this Article but it does not have an example with TemplateColumn.
Can anyone help me with this?
Thanks In Advance
I has trying to addColumns Dinamycally to a RadGrid
Here is the Code Snippet
| protected void Page_Load(object sender, EventArgs e) |
| { |
| if (!IsPostBack) |
| { |
| // SET GRID VIEW |
| setGridEvoColumns(RadGridEvoStats); |
| } |
| } |
| public void setGridEvoColumns(RadGrid Grid,ArrayList years, DataTable Source) |
| { |
| GridBoundColumn boundColumn; |
| GridTemplateColumn gtc; |
| StatsColumn sc; |
| StatsColumnHeader sch; |
| boundColumn = new GridBoundColumn(); |
| Grid.MasterTableView.Columns.Add(boundColumn); |
| boundColumn.HeaderText = "Country"; |
| boundColumn.DataField = "Country"; |
| boundColumn.UniqueName = "Country"; |
| string sufix = ""; |
| foreach (string year in years) |
| { |
| sufix = "_" + year; |
| gtc = new GridTemplateColumn(); |
| sc = new StatsColumn(); |
| sch = new StatsColumnHeader(); |
| Grid.MasterTableView.Columns.Add(gtc); |
| gtc.HeaderTemplate = sch; |
| gtc.ItemTemplate = sc; |
| } |
| } |
I create a custom Header and ItemTemplate to the GridTemplateColumn
The Problem is when there are a PostBack on Page the TemplateColumns are cleared (lost their header values as Item values), but bound columns mantain theirs values and Headers.
I'm using NeedDataSource Event to Bound The Grid Also.
I Have already read this Article but it does not have an example with TemplateColumn.
Can anyone help me with this?
Thanks In Advance
