Accessing controls in the edititemtemplate of a listview

前端 未结 6 1947
半阙折子戏
半阙折子戏 2021-01-06 10:38

I am working with the listview control. By default I am showing the itemtemplate with an edit button. When the edit button is pressed the listview switches to the edititemte

6条回答
  •  不要未来只要你来
    2021-01-06 11:15

    this is similar to the accepted answer, but I think its author was really driving towards this:

    protected void UnitsLV_ItemDataBound(object sender, ListViewItemEventArgs e)
    {
        ListViewDataItem listViewDataItem = e.Item as ListViewDataItem;
        if (UnitsLV.EditIndex == listViewDataItem.DataItemIndex)
        {
            // Controls within the edititemtemplate are available via e.Item.FindControl("controlname")
        }
    }
    

提交回复
热议问题