在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
在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