0

I am calling a webmethod from an aspx page. The webmethod is in code behind only. Now, I want to know if it is possible to call a method from the webmethod?

For example:

//Simple Method
Public static void BindData()
{
   // Bind DataList using DataTable
}

[WebMethod]
Public static void InsertData()
{
   // Call BindData()
}

Here, I am getting error for DataList control as it must use static type. Why?

J. Steen
  • 15,470
  • 15
  • 56
  • 63
Jeeten Parmar
  • 5,568
  • 15
  • 62
  • 111

1 Answers1

0

You cannot access controls in static methods. Your webform is a class and controls are properties of this class and they are non-static so you cannot access non-static properties in static method. You can use ajax to populate datalist.

Mairaj Ahmad
  • 14,434
  • 2
  • 26
  • 40