asp.net - An object reference is required for the non-static field, method, or property '_Default.RadioButtonList2' -


i have gridview bind data database using stored procedure.

below part of code behind error above:

[webmethod] public static string getlist(int pageindex){  ....  ..... cmd.parameters.addwithvalue("@customergroup", radiobuttonlist2.selectedvalue); //error here .... ....  } 

i have code 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> 

how value of radio button selected , pass stored procedures? when remove line code working.

problem have created webmethod, can not access server controls. remove it.

if required, pass radiobuttonlist2.selectedvalue in function client side.

[webmethod] public static string getlist(int pageindex,string radiovalue){  ....  ..... cmd.parameters.addwithvalue("@customergroup", radiovalue);  .... ....  } 

hope works.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -