Hello ng,
I have a datagrid that is bound to a datasource. That works good so far. Now
I want to add another column to my grid dynamically. That also works good
until the first postback. The column is still there but for some reason its
content is empty. I added the code underneath this post. The problem is that
the delegate CreateCellTempl ate is not called anymore. But why? I can't
understand.. :-( Viewstate is enabled for the grid.
Code
(The grid is an infragistics one. however, i think that has no impact in
that case.)
protected void Page_Load(objec t sender, EventArgs e) {
if (!Page.IsPostBa ck) {
// add column dynamically to grid
TemplatedColumn col = new TemplatedColumn (true);
col.CellTemplat e = new CompiledTemplat eBuilder(new
BuildTemplateMe thod(CreateCell Template));
myGrid.Columns. Insert(1, col);
}
}
private void CreateCellTempl ate(Control container) {
CellItem currentItem = (CellItem) container;
// cast it into my business object
InvoiceEntity dataItem = (InvoiceEntity) currentItem.Dat aItem;
CheckBox chkBox = new CheckBox();
chkBox.ID = "baseList." + dataItem.Id;
container.Contr ols.Add(chkBox) ;
}
Thanks in advance for your help!
Regards Roger