problem with display of gridview in asp.net
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
开发者_JAVA百科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:
I don't understand this. Why am I getting the same columns rendered twice?
Set AutoGenerateColumns = "False" on your GridView
If you're manually handling the columns, is AutoGenerateColumns set to false
?
Set autogenerateColumns = false;
精彩评论