I am working on a project(ASP.NET website) where i need to call method in webpage from a class.
///Default Page Method is
public partial class _Default :
You should be returning only data from business rule class and bind grid view in the code behind class.
you can make method in the class which will return the List
and on page load bind it with your girdview:
public class BLMethods
{
public BLMethods()
{
}
public List GetPersons()
{
List objPersonList = new List();
clsPerson objPerson = new clsPerson();
objPerson.personID = i;
objPerson.personName = "Person" + i;
objPersonList.Add(objPerson);
return objPersonList ;
}
}
and in code behind of page:
protected void Page_Load(object sender, EventArgs e)
{
BindGridView();
}
public void BindGridView()
{
BLMethods objBLMethods = new BLMethods();
GridView1.DataSource = objBLMethods.GetPersons();
GridView1.DataBind();
}