0

我有一个gridview,我使用存储过程与数据库中的数据绑定。

下面是我得到上述错误的部分代码:

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

我有这个gridview的代码:

<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 回答