1

I'm displaying a GridView using the following markup in my default.aspx:

<Columns>
  <asp:BoundField DataField="SNo" HeaderText="SNo" />
  <asp:BoundField DataField="ComponentName" HeaderText="Component Name" />
  <asp:BoundField DataField="Size" HeaderText="Size" />
  <asp:BoundField DataField="price" HeaderText="Price" />
  <asp:BoundField DataField="TotalDownloads" HeaderText="Total Downloads" />
  <asp:BoundField DataField="Description" HeaderText="Description" />
</Columns>

In the codebehind default.aspx.cs I have:

var result = (from Component comp in db 
              orderby comp.SNo 
              select new { 
                  SNo = comp.SNo, 
                  ComponentName = comp.ComponentName, 
                  Size = comp.Size, 
                  Price = comp.Price, 
                  TotalDownloads = comp.TotalDownloads, 
                  Description = comp.Description 
               }).ToList();

ComponentGridView.DataSource = result;
ComponentGridView.DataBind();

But the GridView looks like this:

enter image description here

I don't understand this. Why am I getting the same columns rendered twice?

3 Answers 3

4

Set AutoGenerateColumns = "False" on your GridView

Sign up to request clarification or add additional context in comments.

Comments

2

If you're manually handling the columns, is AutoGenerateColumns set to false?

Comments

1

Set autogenerateColumns = false;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.