Hi experts,
I would like to populate GridView using Stored Procedure and SqlDataSource in ASP.NET.
My Stored Procedure has 4 select statements that returns multiple recordsets.
My issue is I don't know how to call the columns from the 2nd and 3rd select statement from the same Stored Procedure in SqlDataSource Gridview
The code below works fine for any column that comes from the 1st Select statement.
As soon as I introduce another column (Cost) from the 2nd, 3rd, or 4th Select statement then I get the error message:
'DataBinding: 'System.Data.DataRowView' does not contain a property with the name.
I got that error message because by default it points to the first select statement and since (Cost) column is not in the first Select statement (even though it is in the 2nd Select statement) it is throwing me that error.
Below is my code:
<table border="1">
<tr>
<td>
Product
</td>
<td>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Product") %>'> </asp:Label>
</td>
</tr>
==>Work ok
<tr>
<td>
Cost
</td>
<td>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("Cost") %>'> </asp:Label>
</td>
</tr>
==>Display error above
</table>
</ItemTemplate> </asp:DataList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnString %>"
SelectCommand="GetDetails_SP" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:QueryStringParameter Name="Product_ID" QueryStringField="Product_ID" Direction="Input"
DefaultValue="" ConvertEmptyStringToNull="True" />
</SelectParameters>
</asp:SqlDataSource>
Your help is greatly appreciated.