Accessing controls in the edititemtemplate of a listview

前端 未结 6 1911
半阙折子戏
半阙折子戏 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条回答
  •  -上瘾入骨i
    2021-01-06 11:27

    protected void UnitsLV_ItemEditing(object sender, ListViewEditEventArgs e) 
    { 
        ListViewItem item = UnitsLV.Items[e.NewEditIndex]; 
        ListBox tempLB = (ListBox)e.item.FindControl("ListBox3"); 
    } 
    

    I believe I found a typo in the above function. The second line should be

    ListBox tempLB = (ListBox)item.FindControl("ListBox3"); 
    

    What I did was replace "e.item" with "item"

提交回复
热议问题