Dear All,
I am using asp.net2.0, C#, sql2005 using Visual studio 2005
Let Me explain the scenario I have checkboxlist containg 15 field. Based on no of checked field . I created dropdownlistbox and label dynamically through loop and assign id as dropdownlist + no of iteration. Now my question is how I access these control as when I am accessing one of the control I am getting nullobjectrefer ence error stating “Object reference not set to an instance of an object.”
I created control as
Foreach(listite m)
{
//…….
Label label = new Label();
DropDownList dropdownlist = new DropDownList();
//assinging id
label.ID = "label" + i.ToString() ;
dropdownlist.ID = "dropdownli st" + i.ToString() ;
}
And I am accessing it through
cmd.Parameters. Add("@para1", SqlDbType.VarCh ar).Value = Page.FindContro l("label1").ToS tring() ;
cmd.Parameters. Add("@value1", SqlDbType.VarCh ar).Value = Page.FindContro l("dropdownlist 1").ToString ();
and my second question is how do i access selected value in dropdownlist1(d ynamically created control) Please guide me
Thanks
I am using asp.net2.0, C#, sql2005 using Visual studio 2005
Let Me explain the scenario I have checkboxlist containg 15 field. Based on no of checked field . I created dropdownlistbox and label dynamically through loop and assign id as dropdownlist + no of iteration. Now my question is how I access these control as when I am accessing one of the control I am getting nullobjectrefer ence error stating “Object reference not set to an instance of an object.”
I created control as
Foreach(listite m)
{
//…….
Label label = new Label();
DropDownList dropdownlist = new DropDownList();
//assinging id
label.ID = "label" + i.ToString() ;
dropdownlist.ID = "dropdownli st" + i.ToString() ;
}
And I am accessing it through
cmd.Parameters. Add("@para1", SqlDbType.VarCh ar).Value = Page.FindContro l("label1").ToS tring() ;
cmd.Parameters. Add("@value1", SqlDbType.VarCh ar).Value = Page.FindContro l("dropdownlist 1").ToString ();
and my second question is how do i access selected value in dropdownlist1(d ynamically created control) Please guide me
Thanks
Comment