【发布时间】:2013-10-28 16:07:20
【问题描述】:
我在数据列表中使用下拉列表。现在,我想要下拉选择值 onDatalistItemBound。
如何获得???
【问题讨论】:
我在数据列表中使用下拉列表。现在,我想要下拉选择值 onDatalistItemBound。
如何获得???
【问题讨论】:
您的 ItemDataBound 处理程序应如下所示:
protected void dl_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
var myDropDownList = e.Item.FindControl("YourDropDownListID") as DropDownList;
int currentItemID = int.Parse(this.dl.DataKeys[e.Item.ItemIndex].ToString());
myDropDownList.DataSource = GetDDLDataSource(currentItemID);
myDropDownList.DataBind();
}
}
【讨论】:
Visible = false 然后在您绑定下拉列表并分配下拉列表的同一 itemdatabound 事件中找到该标签 -绑定后down.selectedvalue。