开发者

Pass Parameter to LinqDataSource "OnSelecting" for Stored Procedure

开发者 https://www.devze.com 2022-12-22 17:22 出处:网络
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.

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_开发者_Python百科GetByID(Integer.Parse(e.WhereParameters("ID"))) isn't playing nice...

Exception Details: System.FormatException: Input string was not in a correct format.


The "PropertyName" was incorrect in the WhereParameters.

<asp:ControlParameter ControlID="HiddenID" 
                      PropertyName="Value" 
                      Type="String" 
                      Name="ID" />
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号