FindControl in GridView
Posted on 2006-07-21
I have a DropDownList in the EditItemTemplate of a Gridview Column and need to retrieve its SelectedValue. My code is throwing the
following error: "Object reference not set to an instance of an object"
heres what I have:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
DropDownList ddl = new DropDownList();
ddl = (DropDownList)(GridView1.FindControl("DropDownList1"));
str = ddl.SelectedValue.ToString(); // this line throws the error
See anything wrong here? I'm banging my head!