.net DDL problem

Don
Joined
5 Oct 2005
Posts
11,237
Location
Liverpool
Hi there...

For some reason my DDL, which the code is:

protected void DropDownListSoft_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList DDL_Soft = (DropDownList)SoftList.FindControl("DropDownListSoft");

string No = DDL_Soft.SelectedItem.Value;

}

keeps throwing up the error "Object reference not set to an instance of an object." any ideas why??

Stelly
 
probably because it can't find the control, and returns a null object.

you should not have to use the Findcontrol method though, try and access your control directly instead.
 
Done it...

DropDownList DDL_Soft = (DropDownList)SoftList.FooterRow.FindControl("DropDownListSoft");

Just needed to concentrate and remember it was in the footer of the gridview :)


Stelly
 
DropDownList DDL_Soft = (DropDownList)SoftList.FooterRow.FindControl("DropDownListSoft");

That works fine... need to get the value and insert it into an sqlstatement

Stelly
 
Back
Top Bottom