Hi,
I am creating a grid at runtime (code behind) which could be either in view or edit mode depending on a user selection.
I have two ways to display the grid in view or edit mode.
For view mode:
Using the GridBoundColumn like below
Or use GridTemplateColumn like below with ViewTemplate implementing ITemplate.
For edit mode:
Use GridTemplateColumn, set the columns in edit mode (true/false) using the PreRender event. ItemTemplate and EditItemTemplate would be used depending view/edit.
Or use only GridTemplateColumn with ItemTemplate with textbox controls for edit. And use GridBoundColumn for view mode. This way I don't need to loop through the columns in the prerender event to set the columns to edit mode. By using the GridTemplateColumn I would have the columns set to edit mode.
I am leaning towards the last option, I would like to know your opinion. Thanks!
I am creating a grid at runtime (code behind) which could be either in view or edit mode depending on a user selection.
I have two ways to display the grid in view or edit mode.
For view mode:
Using the GridBoundColumn like below
| 'if the field is always in view mode, no editing of data |
| column = New GridBoundColumn() |
| column.DataField = controlID 'eg "COL1" |
| column.UniqueName = controlID |
| grid.MasterTableView.Columns.Add(column) |
Or use GridTemplateColumn like below with ViewTemplate implementing ITemplate.
| column = New GridTemplateColumn() |
| column.ItemTemplate = New ViewTemplate(controlID) |
For edit mode:
Use GridTemplateColumn, set the columns in edit mode (true/false) using the PreRender event. ItemTemplate and EditItemTemplate would be used depending view/edit.
Or use only GridTemplateColumn with ItemTemplate with textbox controls for edit. And use GridBoundColumn for view mode. This way I don't need to loop through the columns in the prerender event to set the columns to edit mode. By using the GridTemplateColumn I would have the columns set to edit mode.
I am leaning towards the last option, I would like to know your opinion. Thanks!