Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Data Displayed Twice In Gridview (ASP.NET)

I'm trying to make a page where information from the database are displayed on a page. For this, I'm using a Gridview control. The data displays fine, but it displays the same information twice. So basically, two tables are drawn by ASP and placed side by side.

Heres 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>

Also, the SQL Stored Procedure is pulling all of the fields required by the Gridview. The SQL is basically

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

So I'm not requesting the information twice using the Stored Procedure.

I've started ASP.NET in July, so I apologise now if this is something really simple.

Thanks! Michael

like image 887
mickburkejnr Avatar asked Oct 12 '10 10:10

mickburkejnr


1 Answers

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

If you choose the former method your grid definition will become:

<asp:GridView ID="PackagesGV" runat="server" Width="520px" AutoGenerateColumns="False">
like image 72
ChrisF Avatar answered Sep 28 '22 07:09

ChrisF