1

它有一个带有 LayoutTemplate、ItemTemplate 和 EditTemplate 的 ListView。列表视图只显示一项。ItemTemplate 作为带有 CommandName = 'Edit' 的 EditButton,单击时触发...

Protected Sub ListView1_ItemEditing(ByVal sender As Object, ByVal e As ListViewEditEventArgs) Handles ListView1.ItemEditing

    ListView1.EditIndex = e.NewEditIndex

    'Create SQL and load result in datatable and bind to listview 
    LoadData(Session("SID"))

End Sub

EditTemplate 有一个带有 CommandName 'Update' 的 UpdateButton,单击它会触发...

Protected Sub ListView1_Command(ByVal sender As Object, ByVal e As ListViewCommandEventArgs) Handles ListView1.ItemCommand

    If e.CommandName = "Update" Then

        'Use StringBuilder to build up an UPDATE TSql script
        SqlStr = sb.ToString
        'Execute Update
        ExecuteSQLScript(SqlStr)

    End If

上面的效果很好。我的问题是我现在如何回到 ItemTemplate 视图。我知道我必须使用类似于上述 ItemEditing 方法工作方式的 ItemUpdating 方法,但我已经没有想法了......感谢任何帮助。我现在只有...

 Protected Sub ListView1_Updating(ByVal sender As Object, ByVal e As ListViewUpdateEventArgs) Handles ListView1.ItemUpdating

    'ListView1.ItemIndex = e.ItemIndex  'This does not work

    LoadData(Session("SID"))

End Sub

谢谢

4

1 回答 1

4

设置EditIndex-1

ListView1.EditIndex = -1
于 2013-02-10T10:27:25.910 回答