Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a stord procedure called EXEC [usp_GetDetail] will return multiple results.I need to display those Different datasets in a single webpage using Different DataGrids.
Posted
Updated 15-Jun-12 5:39am
v2
Comments
Maciej Los 21-May-12 12:50pm    
Where is a problem? What have you done so far? Have you read this?
John Orendt 23-May-12 0:14am    
Does usp_GetOwnerDetail return a DataSet with multiple tables?
myansweris 23-May-12 9:42am    
Yes it has multitables, but mu problem is to display those results in a collapsed panel like SQL server Dashboard
John Orendt 23-May-12 13:36pm    
Sorry, I don't know what you mean by "a collapsed panel like SQL server Dashboard"?
myansweris 24-May-12 10:33am    
Ok let me put it in this way ---- stored proc returns multiple values like 46 columns, and i want to display those values Horizontally , so that panel needs side by side diaplay.
Ex:-- sqlserver --> rightclick on databaseserver --->reports--->standardreports--->Server Dashboard
there u find this collapsed panels (CPU Usage)
I just want to desplay my panel exactly like that ... Any help ?

If you're going to receive multiple result set from the procedure you need to enable MARS[^]. Then when reading the data, if you use for example a SqlDataReader, use NextResult[^] to advance in the results.
 
Share this answer
 
Comments
Espen Harlinn 22-May-12 18:08pm    
Excellent :-D
Wendelius 23-May-12 1:27am    
Thanks :)
Prasad_Kulkarni 23-May-12 0:24am    
Great +5!
Wendelius 23-May-12 1:27am    
Thank you :)
myansweris 24-May-12 10:30am    
THanks
hi,

.aspx
C#
<form id="form1"  runat="server">
<div>
    <asp:panel id="PanelResult" runat="server">
    </asp:panel>
</div>
</form>


.aspx.cs
C#
DataSet dsResult = getDataSet("EXEC usp_GetOwnerDetail;");

for (int intTables = 0; intTables < dsResult.Tables.Count; intTables++)
{
    GridView gvTable = new GridView();
    gvTable.ID = "gv" + intTables;
    gvTable.DataSource = dsResult.Tables[intTables];
    gvTable.DataBind();

    PanelResult.Controls.Add(gvTable);
}
 
Share this answer
 
v2
if you have already added grid view control
then set datasource to all gridviews

C#
DataSet dsResult = getDataSet("EXEC usp_GetOwnerDetail;");
GridView1.DataSource=dsResult.Tables[0];
GridView2.DataSource=dsResult.Tables[1];
GridView2.DataSource=dsResult.Tables[2];
Page.DataBind();


if you have not added then

You can add GridView Direct on page

or create a asp:Panel on Page and Add All Grids to this Panel
like
Una Yu write
 
Share this answer
 
Comments
myansweris 24-May-12 16:57pm    
Thank you for u r reply , when i execute my stored Proc --i have 2 data sets one with primaryKey(ServerId) So i can retrieve ---> But iam unable to retrieve the second dataset because that doesn't have any Primary key to call in a Panel.so what is the best option to do?
Presumably you have added a way to differentiate between the datasets? Using that difference in a where clause would probably be the simplest way of doing this.
 
Share this answer
 
Comments
myansweris 21-May-12 12:00pm    
I don't want to Modify my StoredProc...Just need to diaplay Storedproc multiple set results in a single page using DataGrid
R. Giskard Reventlov 21-May-12 12:06pm    
Did I say that you should? Apply the where clause to the logic that selects the data for each gridview.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900