学无止境

-------至弱即为至强!

导航

在DataGrid中实现无刷新编辑列的代码(VB.NET 2003)

Posted on 2006-06-16 09:04  赵国亮  阅读(1933)  评论(3编辑  收藏  举报
        在VB.NET 2003的DataGrid中,通过使用编辑列可以在页面中实现一种无刷新效果,其实现代码如下:

        在DataGrid的EditCommand事件中代码如下:
        Private Sub DataGrid_EditCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid.EditCommand
            DataGrid.EditItemIndex = e.Item.ItemIndex
            '数据绑定
            BindData()
        End Sub

        在DataGrid的UpdateCommand事件中代码如下:
        Private Sub DataGrid_UpdateCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid.UpdateCommand
            '数据更新
            Update()
            DataGrid.EditItemIndex = -1
            '数据绑定
            BindData()
        End Sub

        在DataGrid的CancelCommand事件中代码如下:
        Private Sub DataGrid_CancelCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid.CancelCommand
            DataGrid.EditItemIndex =  -1
            '数据绑定
            BindData()
        End Sub