I am trying to bind a label to a SqldataSource that uses a storedProcedure, but get the following error: "An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll"
Protected Sub SqlDataSource_GetHandicap_Selected(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) Handles SqlDataSource_GetHandicap.Selected
Dim dv As Data.DataView = SqlDataSource_GetHandicap.Select(DataSourceSelectArguments.Empty)
lblHC.Text = dv.ToTable.Rows(0)("HC")
End Sub
********************************************
<asp:SqlDataSource ID="SqlDataSource_GetHandicap" runat="server"
ConnectionString="<%$ ConnectionStrings:New_ASPNET %>"
SelectCommand="Golf_GetPLayerHandicap2"
SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="DataList_Membership" Name="PlayerID"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
Handicap Index = <asp:Label ID="lblHC" runat="server" ></asp:Label>
Since you've used a SqlDataSource to bind to the GridView successfully, and I think you can just fetch out the value from the GridView without anything else to cope with.
Sample——In the page_Load event,You can try this:
lblHC.Text = GridView1.Rows(0).Cells(Index Of "HC") .Text
Marked as answer by john1506 on Nov 27, 2012 04:31 PM
john1506
Member
319 Points
448 Posts
SqlDataSource - StoredProcedure- label
Nov 25, 2012 02:51 PM|LINK
I am trying to bind a label to a SqldataSource that uses a storedProcedure, but get the following error: "An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll"
Protected Sub SqlDataSource_GetHandicap_Selected(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) Handles SqlDataSource_GetHandicap.Selected Dim dv As Data.DataView = SqlDataSource_GetHandicap.Select(DataSourceSelectArguments.Empty) lblHC.Text = dv.ToTable.Rows(0)("HC") End Sub ******************************************** <asp:SqlDataSource ID="SqlDataSource_GetHandicap" runat="server" ConnectionString="<%$ ConnectionStrings:New_ASPNET %>" SelectCommand="Golf_GetPLayerHandicap2" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:ControlParameter ControlID="DataList_Membership" Name="PlayerID" PropertyName="SelectedValue" Type="Int32" /> </SelectParameters> </asp:SqlDataSource> Handicap Index = <asp:Label ID="lblHC" runat="server" ></asp:Label>Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: SqlDataSource - StoredProcedure- label
Nov 26, 2012 03:40 AM|LINK
Hello,
Since you've used a SqlDataSource to bind to the GridView successfully, and I think you can just fetch out the value from the GridView without anything else to cope with.
Sample——In the page_Load event,You can try this:
nikunjnandan...
Participant
882 Points
223 Posts
Re: SqlDataSource - StoredProcedure- label
Nov 27, 2012 04:31 AM|LINK
Hii,
I don't know why you are using sql datasource.
I think if it's only lable not nested in grid then direct you do like lbl.text = dt.Rows(0)("ProgressStatus").ToString()
And if it's nested in grid then
<asp:Label id="lblProgress" runat="server" text='<%# Eval("FieldName")%>' ></asp:Label>
and in code behind
gv.datasource= dt
gv.databind()
Nikunj Nandaniya
My Blog