-----先谢谢你们,请看看我那里错了,点击[删除]按钮为什么不相应删除动作呢?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;
}
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;
}
解决方案 »
- 我想在C#后台获取前台table的行数?
- 使用FileUpload问题
- 【需求变了】HELP!
- 如何设置在三秒种内跳转到上一个页面呢?
- 用的FCKeditor 的 来看看
- 在asp.net中怎么输出图片?
- 如何给这个SqlCommand对象传递参数@id
- 为什么用户控件中TextBox的值不改变
- 怎么写定时器
- 各位高手。高分求救!当我动态增加RadioButton控件时,如何使所添加的RadioButton控件的RadioButton_CheckedChanged事件起作用?急!!!
- 怎么用程序实现在 Web 站点或虚拟目录上添加 ASPNET 帐户的读取、执行和列出权限 ?
- webtreeview.msi的安装问题
"
中的姓名是不是写错了?应该写information中对应字段吧?比如:Name
private void InitializeComponent()
{
this.DataGrid1.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_DeleteCommand);
}
#endregion
我觉得 itants(郁闷的冰箱)这个的说法就对了阿
在Dbgrid1属性生成器里面将列删除,重新加入,但是一定要先点[应用]后点[确定]
就能找到事件
----郁闷,这是什么道理啊!