dataGridView中如何删除行,非绑定 请问dataGridView中如何删除行,dataGridView中的数据不是和数据库绑定的。我知道选中一行按del键可以删除一行,但我现在需要在代码中删除行。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 参考://删除 protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { string sqlstr = "delete from 表 where id='" + GridView1.DataKeys[e.RowIndex].Value.ToString() + "'"; sqlcon = new SqlConnection(strCon); sqlcom = new SqlCommand(sqlstr,sqlcon); sqlcon.Open(); sqlcom.ExecuteNonQuery(); sqlcon.Close(); bind(); } ds.Tables[0].Rows.Remove(ds.Tables[0].Rows[this.dataGridView1.CurrentRow.Index]); 如下的方法就可以了:this.dataGridView1.Rows.Remove(this.dataGridView1.CurrentRow); 其实二楼的也是需要的,他删除的是数据库中的,this.dataGridView1.Rows.Remove(this.dataGridView1.CurrentRow); 这只删除界面上的 html语句中,window.open的条件语句怎么写 c#中调用webservice的问题 哪个项目外包网可靠 C# 数据库 在.net中制作一个登入窗口的小软件时 用C#如何设置密码错误超过一定次数软件关闭 类型转换。在线等。解决就给分。急 c#winform中对treeview的节点后面添加一个textbox控件,在选择该节点时可以输入内容,并且可以折叠 webform中文件的访问 C#连接Oracle数据库 SqlDataReader 怎么读取这个数据:Select sum(2*CostPrice)'Price' FROM Goods 激活被隐藏的窗口 自己写了一个中文分词组件
//删除
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string sqlstr = "delete from 表 where id='" + GridView1.DataKeys[e.RowIndex].Value.ToString() + "'";
sqlcon = new SqlConnection(strCon);
sqlcom = new SqlCommand(sqlstr,sqlcon);
sqlcon.Open();
sqlcom.ExecuteNonQuery();
sqlcon.Close();
bind();
}