This is a migrated thread and some comments may be shown as answers.

[Solved] Dynamically creating columns and edit form template

1 Answer 143 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Marlayna
Top achievements
Rank 1
Marlayna asked on 24 Jun 2008, 06:56 PM
I am using an older version of the RadGrid, Q1 2006, 3.1.1.0.

The structure and data of the grid is being supplied by an xml file; therefore, there is no way of knowing at design-time how many columns there are and what data they will contain. So, at runtime I want to dynamically create the columns and an edit form template to be used.

Right now, I create the columns and set the edit form template, with an IBindableTemplate class I created, in the OnNeedDataSource event handler. When the page runs the grid all renders fine and clicking the "Edit" of the GridEditCommandColumn functions correctly and displays the Edit Form Template; however, when I click "Delete" of the GridButtonColumn it triggers the OnItemCommand event but by the time it gets there it is gone(CommandName is empty) and the grid renders with just the edit and data columns, all the columns' header text and delete column are gone. Similar issues are occurring when I click the "Update" and "Cancel" of the edit form template.

I assume it is because of where I am creating the columns and have tried various different places to do so to no avail. I even tried extending the RadGrid and using the CreateChildControls() where I have been able to do so with normal asp view controls in the past. Calling Rebind() in the OnInit fixes the "Delete" issue but it only complicates things with "Update" and "Cancel". 

Any suggestions would be greatly appreciated.

Thank you,
Marlayna

1 Answer, 1 is accepted

Sort by
0
Marlayna
Top achievements
Rank 1
answered on 25 Jun 2008, 04:24 PM
Never mind, found a solution.
Tags
Grid
Asked by
Marlayna
Top achievements
Rank 1
Answers by
Marlayna
Top achievements
Rank 1
Share this question
or