!我有一个嵌套的DataList
,我想在DataList
事件上绑定内部button
,但是它没有用,有人有想法吗?
DataList2.FindControl("DataList3").DataBind();
答案 0 :(得分:0)
尝试使用datalist
进行投射((DataList)DataList2.FindControl("DataList3")).DataBind();
答案 1 :(得分:0)
将此代码用于Bind
内部DataList
:
protected void DataList2_ItemDataBound(object sender, DataListItemEventArgs e)
{
if ((e.Item.ItemType == ListItemType.Item) ||
(e.Item.ItemType == ListItemType.AlternatingItem))
{
// get inner datalist
DataList dl3 = e.Item.FindControl("DataList3") as DataList;
// bind inner datalist with data source
dl3.DataSource = dt; // DataTable that contains data
dl3.DataBind();
}
}
注意:强>
确保您已按此输入此事件OnItemDataBound="DataList2_ItemDataBound"
:
<asp:DataList ID="DataList2" runat="server" OnItemDataBound="DataList2_ItemDataBound">