Data Displayed Twice in Gridview (ASP.NET)

I am trying to create a page on which information from a database is displayed on a page. For this, I use the Gridview control. The data is displayed well, but it displays the same information twice. Thus, basically two tables are drawn by ASP and placed side by side.

Here is the code I'm using:

<asp:GridView ID="PackagesGV" runat="server" Width="520px"> <Columns> <asp:BoundField DataField="ID" HeaderText="Package ID"/> <asp:BoundField DataField="PackageName" HeaderText="Package Name"/> <asp:BoundField DataField="PackageText" HeaderText="Package Text"/> <asp:BoundField DataField="PackageImageID" HeaderText="Package Image"/> <asp:BoundField DataField="PageID" HeaderText="Page ID"/> </Columns> </asp:GridView> 

In addition, the SQL Stored Procedure extends all the fields required by the Gridview. SQL is basically

"SELECT [ID], [PackageName], [PackageText], [PackageImageID], [PageID] FROM [Packages]"

Therefore, I do not request information twice using the stored procedure.

I started ASP.NET in July, so I apologize if this is something very simple.

Thanks! Michael

+4
source share
1 answer

You need to either set the GridView.AutoGenerateColumns Property to false , or not configure the columns.

If you choose the old method, your grid definition will be as follows:

 <asp:GridView ID="PackagesGV" runat="server" Width="520px" AutoGenerateColumns="False"> 
+19
source

All Articles