在ListView中获取按钮点击上的下拉列表selectedvalue

本文关键字:下拉列表 selectedvalue ListView 获取 按钮 | 更新日期: 2023-09-27 18:12:56

我在ListView中为每一行设置了下拉列表和按钮。现在我想获得按钮单击事件上的下拉列表的选定值。我怎样才能得到这个?

请指引我。

谢谢。

在ListView中获取按钮点击上的下拉列表selectedvalue

设置按钮的CommandName属性,处理列表视图的ItemCommand事件,并使用FindControl来查找下拉列表。

参考

DropDownList.SelectedValue将获得当前选择的值。

编辑:重新考虑后,使用TC..


在按钮单击事件中执行如下操作:

Button b = (Button)sender;
DropDownList ddl = (DropDownList)b.Parent.FindControl("DropDownList ID");
string DropDownListSelectedValue = ddl.SelectedValue;