Pass Parameter to LinqDataSource "OnSelecting" for Stored Procedure
Posted
by rockinthesixstring
on Stack Overflow
See other posts from Stack Overflow
or by rockinthesixstring
Published on 2010-03-14T02:36:51Z
Indexed on
2010/03/14
2:45 UTC
Read the original article
Hit count: 743
linqdatasource
I'm building a semi-elaborate RadGrid where within my NestedViewTemplate I want to have a LinqDataSource that uses a Stored Procedure to get data from the database.
Here's what I have so far
<asp:HiddenField runat="server" ID="HiddenID" Value='<%#DataBinder.Eval(Container.DataItem, "ID")%>' />
<asp:LinqDataSource ID="LinqDataSource1" runat="server" OnSelecting="LinqDataSource_Selecting">
<WhereParameters>
<asp:ControlParameter ControlID="HiddenID" PropertyName="ID" Type="String" Name="ID" />
</WhereParameters>
</asp:LinqDataSource>
any my Code Behind...
Protected Sub LinqDataSource_Selecting(ByVal sender As Object, ByVal e As LinqDataSourceSelectEventArgs)
Dim hdc As New DAL.HealthMonitorDataContext()
e.Result = hdc.bt_HealthMonitor_GetByID(Integer.Parse(e.WhereParameters("ID")))
End Sub
but unfortunately hdc.bt_HealthMonitor_GetByID(Integer.Parse(e.WhereParameters("ID")))
isn't playing nice...
Exception Details: System.FormatException: Input string was not in a correct format.
© Stack Overflow or respective owner