dpmoney
asked on
ASP.NET - Bind Gridview Datasource to a specific table in dataset
I have a functioning test ASPX page that calls a SINGLE SQL stored procedure.
That stored procedure returns 5 recordsets.
In the page load event, I'm able to fill a dataset with 5 distinct tables - one for each of the recordsets returned by the single SQL SP.
I know it is working because my response.write test code display the first column's field value from each table.
Now, I just need to figure out how to display this data as 5 distinct tables in the ASPX.
I was thinking 5 distinct gridviews since I can stylize them to my liking, sort etc.
However, how do I bind a gridview datasource to a specific table in a dataset?
Here is some of the page load code which works fine:
'Troubleshooting - Verify data is filled
Response.Write("Recordset #1: " & ds.Tables(0).Rows(0)("Loca tion").ToS tring & "<br />")
Response.Write("RecordSet #2: " & ds.Tables(1).Rows(0)("User name").ToS tring & "<br />")
Response.Write("RecordSet #3: " & ds.Tables(2).Rows(0)("Shap e").ToStri ng & "<br />")
Response.Write("RecordSet #4: " & ds.Tables(3).Rows(0)("Coun try").ToSt ring & "<br />")
Response.Write("RecordSet #5: " & ds.Tables(4).Rows(0)("MfgD ate").ToSt ring & "<br /><br />")
What I need is GridView1 bound to ds.Tables(0), GridView2 bound to ds.Tables(1), etc.
This does not work in the pageload:
GridView1.DataSource = ds.Tables(0)
GridView1.DataBind()
It fails with: 'GridView1' is not declared. It may be inaccessible due to its protection level.
That stored procedure returns 5 recordsets.
In the page load event, I'm able to fill a dataset with 5 distinct tables - one for each of the recordsets returned by the single SQL SP.
I know it is working because my response.write test code display the first column's field value from each table.
Now, I just need to figure out how to display this data as 5 distinct tables in the ASPX.
I was thinking 5 distinct gridviews since I can stylize them to my liking, sort etc.
However, how do I bind a gridview datasource to a specific table in a dataset?
Here is some of the page load code which works fine:
'Troubleshooting - Verify data is filled
Response.Write("Recordset #1: " & ds.Tables(0).Rows(0)("Loca
Response.Write("RecordSet #2: " & ds.Tables(1).Rows(0)("User
Response.Write("RecordSet #3: " & ds.Tables(2).Rows(0)("Shap
Response.Write("RecordSet #4: " & ds.Tables(3).Rows(0)("Coun
Response.Write("RecordSet #5: " & ds.Tables(4).Rows(0)("MfgD
What I need is GridView1 bound to ds.Tables(0), GridView2 bound to ds.Tables(1), etc.
This does not work in the pageload:
GridView1.DataSource = ds.Tables(0)
GridView1.DataBind()
It fails with: 'GridView1' is not declared. It may be inaccessible due to its protection level.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks! Your example code pointed me in the right direction!
ASKER