i have a custom class List on my page code behind:
public List<Category> Categories = new List<Category>();
now, i have also a user control on that page which is supposed to display that list.
how can i access the list from the usercontrol,
or, can i create a list directly in the usercontrol from the page?
my User Control codebehind:
public List<Category> Categories = new List<Category>();
protected void Page_Load(object sender, EventArgs e)
{
}
public class Category
{
public string category_id { get; set; }
public string category { get; set; }
}
my Page codebehind:
public List<Category> Categories = new List<Category>();
protected void Page_Load(object sender, EventArgs e)
{
Category MyCategory = new Category();
MyCategory.category_id = 1;
MyCategory.category = "sample";
Categories.Add(MyCategory);
}
public class Category
{
public string category_id { get; set; }
public string category { get; set; }
}
since Hasan Khan has started helping me,
but never answered my extra questions… i had to find my own solution.
the way i did it at the end was instead of adding items to the list on the Page,
adding them directly to the user control like so:
i dont know if this is a good solution, but at least it works.
if somebody will supply a better answer ( with sample code ) , i will try and use them, meanwhile, this is what i have.