gane said:
Hi,
I am creating datagrid bound column dynamically and need to check if a
datagrid column already exists?Is there a way to check this?
Dynamically created columns do not persist between page loads so I'm not
sure why you need to check.You should only dynamically create and add
columns to a datagrid in the Page_Init event. From online help:
The DataGrid control does not store the contents of its Columns
collection into the view state. To add or remove a column dynamically,
you must programmatically add or remove the column everytime the page is
refreshed. Provide a Page_Init function that adds or removes the column
before the DataGrid control's state is reload and the control is
rebuilt. Otherwise, the changes to the Columns collection are not
reflected in the DataGrid control when it is displayed.
Note Although you can programmatically add columns to or remove
columns from the Columns collection of the DataGrid control, it is
easier to list the columns statically and then use the Visible property
to display or hide each column.