【问题标题】:How to switch back to EditTemplate after an Update to ItemTemplate in a ListViewListView 中的 ItemTemplate 更新后如何切换回 EditTemplate
【发布时间】:2013-02-10 10:21:30
【问题描述】:

它有一个带有 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

谢谢

【问题讨论】:

    标签: asp.net listview itemtemplate edititemtemplate


    【解决方案1】:

    EditIndex 设置为-1

    ListView1.EditIndex = -1
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-04-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多