开发者

Will this code get the value of the found control? asp.net syntax

x.Parameters.AddWithValue("@areasexpertise1", FindControl("AreasExpertise1"))

It should find AreasExpertise1 and make a paramete开发者_JS百科r, 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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜