x.Parameters.AddWithValue("@areasexpertise1", FindControl("AreasExpertise1"))
它应该找到AreasExpertise1并创建一个参数,但这样做也会得到selectedvalue吗?
答案 0 :(得分:1)
您发布的代码将找到该控件,并将其作为Control
对象返回。
您需要将其强制转换为任何控件(DropDownList或RadioButtonList,或者您正在使用的任何控件),然后在其上调用SelectedValue
属性以执行此操作:
var ctrl = FindControl("AreasExpertise1") as DropDownList;
if (ctrl != null)
x.Parameters.AddWithValue("@areasexpertise1", ctrl.SelectedValue)