private void DataGrid1_DeleteCommand(object source, 
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
   int rowToDelete = e.Item.ItemIndex;
   // Add code to delete row from data source.
   DataGrid1.DataBind();
}private void DataGrid1_UpdateCommand(object source, 
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
   // The quantity is in the 7th column.
   TableCell quantityCell = e.Item.Cells[6];
   
   // The TextBox is the 0th element of the Controls collection.
   TextBox quantityBox = (TextBox)quantityCell.Controls[0];   // Extract the quantity from the box.
   int quantity = System.Int32.Parse(quantityBox.Text);   // Use quantity to update the data source.   // Switch out of edit mode.
   DataGrid1.EditItemIndex = -1;
   DataGrid1.DataBind();
}忘了问是winform还是webform
不过原理是一样的把