Gridview Duplicate Columns When Datatable set as datasource programatically and bound fields used

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
Who is Participating?
Carl TawnConnect With a Mentor Systems and Integration DeveloperCommented:
Make sure you turn of "AutoGenerateColumns" if you are manually adding them as well.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.