I have a DataTable which I have created in code file and I later bind it to a GridView which i have created by using the drag and drop feature of Visual studio.
However I have added some columns in the GridView which are not supported(correct me if I am wrong) in a DataTable, e.g Hyperlink-Column or CheckBox-Column.
I would like to build the hyperlink column and the checkbox id’s with a value derived from a value generated in the DataTable from a particular column. I know I can use DataNavigateUrlfields to build dynamic links but how do I do this with a DataTable that is to be bound later?
I also need the columns in the GridView to appear after the columns in the DataTable.
Any help in the above will be highly appreciated. Any alternatives are also appreciated.
Declaratively added controls will be created first and then the databound/manually created(documented in the Page’s Lifecycle, search for “controls created declaratively”). Since you want the declarative columns last, you need a hack:
You could use
RowDataBoundto change the order, so that theAutoGeneratedcolumns are followed by your other columns likeHyperlinkorCheckBoxcolumns:They don’t need to be supported in the DataTable but in the GridView. The table contains your data and the grid contains the view.