ASP Stored Procedure for GridView

I am trying to use an existing stored procedure to populate a gridview.

First, I execute the stored procedure and use the SqlAdapter to put it in the DataSet. I know this works because DataSet.Tables [0] contains my data. However, when I create a GridView and bind data to a GridView, nothing is displayed.

Here is the code for binding the GridView:

DataSet ds = Execute_spr();
GridView testGridView = new GridView();

if (ds.Tables.Count > 0)
{
   testGridView.DataSource = ds.Tables[0].AsEnumerable();
   testGridView.DataBind();
}

and here is the code for my gridview on the .aspx page:

<asp:GridView ID="testGridView" runat = "server" AutoGenerateColumns = "true" />

Any idea what I can do wrong?

Edit: I tried ds.Tables [0] without AsEnumerable () and used .DefaultView

+3
source share
1 answer

Gridview

GridView testGridView = new GridView();

, "testGridView", , -...

+2

Source: https://habr.com/ru/post/1750328/


All Articles