x.Parameters.AddWithValue("@areasexpertise1", FindControl("AreasExpertise1"))
It should find AreasExpertise1 and make a parameter, but does that get the selectedvalue too?
x.Parameters.AddWithValue("@areasexpertise1", FindControl("AreasExpertise1"))
It should find AreasExpertise1 and make a parameter, but does that get the selectedvalue too?
The code you posted will find the control and will return it as a Control
object.
You need to cast it to whatever control it is (DropDownList or RadioButtonList, or whatever it is you are using), and then call the SelectedValue
property on it in order to do so:
var ctrl = FindControl("AreasExpertise1") as DropDownList;
if (ctrl != null)
x.Parameters.AddWithValue("@areasexpertise1", ctrl.SelectedValue)