Changing column type of GridView with dynamic SQL (variable number of columns / autogeneratecolumns=true)
Posted on 2011-10-21
As you can guess from the title, I have a page that uses a GridView. AutoGenerateColumns is set to true and the SQLDataSource object is fed a dynamic SQL procedure that returns a variable number of columns depending on the value of a DropDownList (also kept in a global class variable). Now, these columns are all rendered as labels. But I need columns 4 and 8 to last-5 to be textboxes. That is, first 7 (except fourth) and last 5 remain labels, the others become textboxes.
How would I go about accomplishing this? Is there any event where I can set this just before the data is dumped? If so, can I also change other properties, like BackColor?
Also, how can I change the header properties separately?