I think the reason behind restricting the web method to be static is to avoid it access the controls of the instance page..Even if you could re-bind the repeater ,the new binded data will not be shown to the user because it will not going to be refereshed
automatically.
DotNetXenon
Member
437 Points
134 Posts
How to call non-static method from static web method
Aug 17, 2009 06:53 PM|LINK
[System.Web.Services.WebMethod]
public static DataSet GetContactName()
{ DataSet ds = new DataSet();
XmlDocument doc = new XmlDocument();
ds.ReadXml(System.Web.HttpContext.Current.Server.MapPath("App_Data/Group.xml"));
LoadData(ds); ?????
}
I need to bind this ds to a repeater control.
public void LoadData(DataSet ds)
{
DataSet ds = GetContactName();
repeaterGroup.DataSource = ds;
repeaterGroup.DataBind();
}
My question is, how to call LoadData from above webmethod. LoadData() method is not recognized from the webmethod.
anas
All-Star
73649 Points
7914 Posts
Moderator
Re: How to call non-static method from static web method
Aug 17, 2009 08:11 PM|LINK
I think the reason behind restricting the web method to be static is to avoid it access the controls of the instance page..Even if you could re-bind the repeater ,the new binded data will not be shown to the user because it will not going to be refereshed automatically.
XIII
All-Star
182690 Points
23458 Posts
ASPInsiders
Moderator
MVP
Re: How to call non-static method from static web method
Aug 17, 2009 08:38 PM|LINK
Be sure to read this article: Why do ASP.NET Ajax page methods have to be static.
Grz, Kris.
Interested in Azure, ASP.NET (MVC), jQuery, WCF, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!