A
Anna Schmidt
Hello,
I'm currently working on a dynamic generation of a Datagrid (without aspx )
files.
the basic Idea is sending a DataTable to my viewDatagrid class, so the
columns are determined and dates/numbers are formatted, styles are set etc.,
that works fine. so need to define fields in the aspx.files
Everything works fine, except I can't change HeaderTexts of
Datagrid.Columns. Besides, I can't bound events to this dynamic dg2.
viewDataGrid vd = new viewDataGrid(myDatatable);
DataGrid dg2 = new DataGrid();
dg2 = vd .GetDataGrid(); // after formatting a new Datagrid is returend
//databind is already happened.
dg2.Columns[1].HeaderText ="Name"; // doesn't work at all, instead
fieldnames from datatable used instead
dg2.ShowHeader = true; ///-->works fine
dg2.ShowFooter = false; ///-->works fine
this.Controls.Add(dg2); // adding in the pageload methods
I think It's because databinding already happened in the GetDataGrid()
method. but how to change headertexts afterwords? i want to set my
headertexts in the aspx.cs file, not in my Helper-Class ???
Has anyone got an idea, why this doesn't work? and why can i change the
general preferences, but not the data?
Or is there a better solution for dynamically creating a datagrid from a
datatable?
any help is appreciated.
Thankyou as.
I'm currently working on a dynamic generation of a Datagrid (without aspx )
files.
the basic Idea is sending a DataTable to my viewDatagrid class, so the
columns are determined and dates/numbers are formatted, styles are set etc.,
that works fine. so need to define fields in the aspx.files
Everything works fine, except I can't change HeaderTexts of
Datagrid.Columns. Besides, I can't bound events to this dynamic dg2.
viewDataGrid vd = new viewDataGrid(myDatatable);
DataGrid dg2 = new DataGrid();
dg2 = vd .GetDataGrid(); // after formatting a new Datagrid is returend
//databind is already happened.
dg2.Columns[1].HeaderText ="Name"; // doesn't work at all, instead
fieldnames from datatable used instead
dg2.ShowHeader = true; ///-->works fine
dg2.ShowFooter = false; ///-->works fine
this.Controls.Add(dg2); // adding in the pageload methods
I think It's because databinding already happened in the GetDataGrid()
method. but how to change headertexts afterwords? i want to set my
headertexts in the aspx.cs file, not in my Helper-Class ???
Has anyone got an idea, why this doesn't work? and why can i change the
general preferences, but not the data?
Or is there a better solution for dynamically creating a datagrid from a
datatable?
any help is appreciated.
Thankyou as.