Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2010-11-15
1
969 Views
Last Modified: 2012-05-10
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:
  <Columns>    
                    <asp:ButtonField Text=" X " ButtonType="button" CommandName="deleteFromList" />
 </Columns>

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:

<gridview>
<column>
    <boundField>
    <boundField>
    <buttonField>
</column>
</gridview>

The data that is displayed in the gridview is as follows
boundData  |  boundData  |  buttonField  |  Redundant Data Field | Redundant Data Field
0
Comment
Question by:mdrapiza
1 Comment
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 34139338
Make sure you turn of "AutoGenerateColumns" if you are manually adding them as well.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question