使用ObjectDataSource时传递参数

时间:2014-04-08 09:56:07

标签: c# asp.net

<asp:ObjectDataSource ID="ds_ShippingServiceProfiles" runat="server"   
     SelectMethod="GetCardStatusValues"
     TypeName="AccountsDataHelper">
</asp:ObjectDataSource>

public static DataTable GetShippingProfiles(long storeID)
{

}

我可以像storeID这样获得new websiteDatahelper().SelectedStoreID.Value

如何在使用ObjectDataSource

时发送storeID参数

1 个答案:

答案 0 :(得分:0)

OnSelecting事件定义处理程序:

<asp:ObjectDataSource ID="ds_ShippingServiceProfiles" runat="server"   
     SelectMethod="GetShippingProfiles"
     TypeName="AccountsDataHelper"
     OnSelecting="ds_ShippingServiceProfiles_Selecting">
</asp:ObjectDataSource>

实施活动:

protected void ds_ShippingServiceProfiles_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
{
     e.InputParameters["storeID"] = new websiteDatahelper().SelectedStoreID.Value;
}