To do this, you can create this type of column through the UI property builder, and select columns, expand button column, and select "Edit, Update, Cancel".
After you create this type of column here is how you handle it's events...
Protected Sub DataGrid1_CancelCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.CancelCommand
DataGrid1.EditItemIndex = -1
DataGrid1.DataSource = Session("my_dataview")
DataGrid1.DataBind()
End Sub
Protected Sub DataGrid1_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.EditCommand
DataGrid1.EditItemIndex = e.Item.ItemIndex
DataGrid1.DataSource = Session("my_dataview")
DataGrid1.DataBind()
End Sub
The rebinding is necessary after setting the EditItemIndex. Here I'm just rebinding it to a dataview that I'm storing as a session variable.
Thursday, July 17, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment