0

ストアド プロシージャを使用してデータベースのデータにバインドする gridview があります。

以下は、上記のエラーが発生するコードの一部です。

[WebMethod]
public static string GetList(int pageIndex){
 ....
 .....
cmd.Parameters.AddWithValue("@customerGroup", RadioButtonList2.SelectedValue); //Error here
....
....
 }

グリッドビューには次のコードがあります。

<asp:RadioButtonList ID="RadioButtonList2" runat="server"  AutoPostBack="True" 
                      Font-Size="1em" EnableViewState="true">
                    <asp:ListItem Value="1">Africa</asp:ListItem>
                    <asp:ListItem Value="2" >America</asp:ListItem>
                    <asp:ListItem Value="3">Europe</asp:ListItem>
                    <asp:ListItem Value="4">Asia/asp:ListItem>
                    <asp:ListItem Value="5">Australia</asp:ListItem>
                </asp:RadioButtonList>

選択したラジオ ボタンの値を取得してストアド プロシージャに渡すにはどうすればよいですか? ラインコードを削除すると、すべてが機能します。

4

1 に答える 1

2

問題は、どのサーバー コントロールにもアクセスできない webmethod を作成したことです。それを除く。

必要な場合は、クライアント側からその関数に RadioButtonList2.SelectedValue を渡します。

[WebMethod]
public static string GetList(int pageIndex,string radiovalue){
 ....
 .....
cmd.Parameters.AddWithValue("@customerGroup", radiovalue); 
....
....
 }

それがうまくいくことを願っています。

于 2013-08-07T12:14:50.080 に答える