<asp:datagrid runat="server" id="mygrid" OnDeleteCommand="doItemDelete" ...>Sub doItemDelete(ByVal objSource As Object, ByVal objArgs As dataGridCommandEventArgs)
...
End Sub

解决方案 »

  1.   

    我已经为datagrid1添加了事件:
    private void DataGrid1_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
    {
    try
    {
    this.Label1.Text="pppppp";
    string delete="DELETE FROM clientinfotb where 消息编号='"+e.Item.Cells[1].Text +"'";
    OleDbCommand comm=new OleDbCommand();
    comm.CommandText=delete;
    comm.Connection=this.oleDbConnection1;
    this.oleDbConnection1.Open();
    comm.ExecuteNonQuery();
    this.oleDbConnection1.Close();
    DataSet ds=new DataSet();
    this.oleDbDataAdapter1.Fill(ds);
    this.DataGrid1.DataSource=ds;
    if(this.DataGrid1.Items.Count==1)
    {
    this.DataGrid1.CurrentPageIndex--;
    }
    this.DataGrid1.DataSource=ds;
    this.DataGrid1.DataBind();
    }
    catch(Exception error)
    {
    this.Label1.Text=error.Message;
    }
    }
    然而点击删除按钮,这个事件并没有触发,我还需要做些什么它才能执行?