Solved

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

Posted on 2010-11-15
1
967 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What .NET URL re-routing tool did I use? 2 36
Entity Framework 7 30
Variable Event ? 3 22
How to make a GridView cell hyperlinked using C# ? 3 14
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

911 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now