解决方案 »

  1.   

    处理OnRowDeleted事件
    http://msdn.microsoft.com/zh-cn/library/system.web.ui.webcontrols.gridviewdeletedeventargs(v=vs.80).aspx
    void CustomersGridView_RowDeleted(Object sender, GridViewDeletedEventArgs e)
      {    // Use the Exception property to determine whether an exception
        // occurred during the delete operation.
        if (e.Exception == null)
        {
          // Use the AffectedRows property to determine whether the
          // record was deleted. Sometimes an error might occur that 
          // does not raise an exception, but prevents the delete
          // operation from completing.
          if (e.AffectedRows == 1)
          {
            Message.Text = "Record deleted successfully.";
          }
          else
          {
            Message.Text = "An error occurred during the delete operation.";
          }
        }
        else
        {
          // Insert the code to handle the exception.
          Message.Text = "An error occurred during the delete operation.";      // Use the ExceptionHandled property to indicate that the 
          // exception is already handled.
          e.ExceptionHandled = true;
        }
        
      }