Gridview Duplicate Columns When Datatable set as datasource programatically and bound fields used
Posted on 2010-11-15
I am trying to add a button field to a gridview that I am populating with a datatable. I would like the button field to be the last column in the gridview. When I just add a colum to the GV like:
<asp:ButtonField Text=" X " ButtonType="button" CommandName="deleteFromList" />
And then create a datatable in code and bind it it puts the button field as the first column.
if I add bound fields that match the datatable before the buttonfield it prints the correct data in the bound fields but also adds the columns again as non bound fields.
For example I have:
The data that is displayed in the gridview is as follows
boundData | boundData | buttonField | Redundant Data Field | Redundant Data Field