Solved

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

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

747 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

10 Experts available now in Live!

Get 1:1 Help Now