Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
ASP .Net
Adding columns dynamically to data grid
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Roger Frei, post: 2931328"] 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 CreateCellTemplate 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(object sender, EventArgs e) { if (!Page.IsPostBack) { // add column dynamically to grid TemplatedColumn col = new TemplatedColumn(true); col.CellTemplate = new CompiledTemplateBuilder(new BuildTemplateMethod(CreateCellTemplate)); myGrid.Columns.Insert(1, col); } } private void CreateCellTemplate(Control container) { CellItem currentItem = (CellItem) container; // cast it into my business object InvoiceEntity dataItem = (InvoiceEntity)currentItem.DataItem; CheckBox chkBox = new CheckBox(); chkBox.ID = "baseList." + dataItem.Id; container.Controls.Add(chkBox); } Thanks in advance for your help! Regards Roger [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
ASP .Net
Adding columns dynamically to data grid
Top