开发者

editing nested listview

开发者 https://www.devze.com 2023-02-22 14:45 出处:网络
i have a listview inside listview... how can i f开发者_高级运维ind innerlistview... how can i gets its(innerlistview) edititem index and bind the control...You need to use the ItemDataBound event of

i have a listview inside listview... how can i f开发者_高级运维ind innerlistview... how can i gets its(innerlistview) edititem index and bind the control...


You need to use the ItemDataBound event of the main ListView, then search the inner control using FindControl(id) and then binding the inner ListView to your desired data source.

Simulating an Order -> Products list:

protected void list_ItemDataBound(object sender, ListViewItemEventArgs e)
{
   if (e.Item.ItemType == ListViewItemType.DataItem)
   {
      ListViewDataItem item = (ListViewDataItem)e.Item;
      Order order = (Order)item.DataItem;
      ListView innerList = (ListView)item.FindControl("innerListID");
      innerList.DataSource = order.Products;
   }
}
0

精彩评论

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