v#.net郁闷的问题,Dbgrid的delete事件为什么响应删除动作呢?我哪里错了,请高人赐教,谢谢!
-----先谢谢你们,请看看我那里错了,点击[删除]按钮为什么不相应删除动作呢?
1 在Web窗体上放置一个Dbgrid1;
2 拖曳OleDbDataAdapter1到Web窗体上,出现“数据适配配置向导”,新建立连接一数据库,
并正确完成向导的配置。此时web窗体自动出现一个OleDbConnection.
3 在Dbgrid1的属性生成器里面[列]-〉[按钮列-〉删除] 添加一删除列。其它数据绑定列正确。
4 我在DataGrid1_DeleteCommand事件下输入:
try
{
string delete ="DELETE FROM information where 姓名='"+e.Item.Cells[1].Text+"'"; //其中Dbgrid的第二绑定列为"姓名"
this.Label6.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();
this.Label6.Text = "dfdfdfd";
}
catch (Exception error)
{
this.Label6.Text = error.Message;
}