ASP.NET content control problem in Master page architecture
-
Hi all I am using ASP.NET 3.0 and I have a list box in content page. I am using Master Page architecture. I am binding data from the database into the listbox. but it gives me error of "object reference not set to an instance of an object". This is what I am doing.. ((ListBox)(this.FindControl("ctl00_ContentPlaceHolder1_lMondayFD1"))).DataSource = ds.Tables[0].DefaultView; Please guys any one can help me
-
Hi all I am using ASP.NET 3.0 and I have a list box in content page. I am using Master Page architecture. I am binding data from the database into the listbox. but it gives me error of "object reference not set to an instance of an object". This is what I am doing.. ((ListBox)(this.FindControl("ctl00_ContentPlaceHolder1_lMondayFD1"))).DataSource = ds.Tables[0].DefaultView; Please guys any one can help me
Are you able to find other controls at the same place ? OR can you try like below : Note: Be sure if your Listbox control defined in Content Place holder
ContentPlaceHolder mpContentPlaceHolder;
ListBox lb;
mpContentPlaceHolder = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1");
if(mpContentPlaceHolder != null)
{
lb=(ListBox ) mpContentPlaceHolder.FindControl("yourListboxid");
if(lb!= null)
{
lb.DataSource = ds.Tables[0].DefaultView;
}
}OR In case List box placed on Master page then use try like this:
ListBox lb = (ListBox ) Master.FindControl("yourListboxid");
if(lb!= null)
{
lb.DataSource = ds.Tables[0].DefaultView;
}Parwej Ahamad R & D with IIS 5.0/6.0
modified on Friday, June 6, 2008 11:59 AM