this.GridView1.DataKeyNames = "Emp_id";//提示错误为无法将类型“string”隐式转换为“string[]”
我的Emp_id是int类型protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string index = GridView1.DataKeys[e.RowIndex].ToString();
SqlConnection con = DB.createconn();
SqlCommand cmd = new SqlCommand("delete from Users where Emp_id='"+index+"'",con);
con.Open();
cmd.EndExecuteNonQuery();
this.Databind();
}
请问如何来改!!
我的Emp_id是int类型protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string index = GridView1.DataKeys[e.RowIndex].ToString();
SqlConnection con = DB.createconn();
SqlCommand cmd = new SqlCommand("delete from Users where Emp_id='"+index+"'",con);
con.Open();
cmd.EndExecuteNonQuery();
this.Databind();
}
请问如何来改!!
解决方案 »
- 如何在帖子里面发图片啊
- 那位大师进来帮忙看看难题 我想对 excle 进行操作.........
- 在c#中如何关闭进程。
- ComboBox的问题, 怎么遍访比对ComboBox的值呢?
- 一个很大的程序代码,有很多层,转来转去的,手上没有uml图,要把这段代码全部理解,除了一遍一遍的看以外,各位都有什么好的方法?
- 关于强类型的DataSet??
- 100请教各位高手!急!
- C# 如何能快速生成大量行数的datatable
- 限制用户在文本框中的输入内容——有的只能输入一定长度的文字,有的只能输入数字
- 一个CSV格式文件如何导入到一个datatable中?
- 如何将combBox选择的Item赋给一个变量~
- ftp问题 FtpPutFile()急急!!
{
string index = GridView1.DataKeys[e.RowIndex].ToString();
SqlConnection con = DB.createconn();
SqlCommand cmd = new SqlCommand("delete from Users where Emp_id="+index+"",con);
con.Open();
cmd.EndExecuteNonQuery();
this.Databind();
con.Close();
}
就这个就行了
dataGridView1.Focus();
SendKeys.Send("{DEL}");
for (int i = 0; i < dataGridView1.SelectedRows.Count; i++)
{
String AdminName = dataGridView1.Rows[dataGridView1.SelectedRows[i].Index].Cells[0].Value.ToString();
//MessageBox.Show(AdminName.ToString());
String Sql_Delete = "Delete Admin_Info Where Admin_Name = @AdminName";
SqlConnection Conn = new SqlConnection(SQLHelp.CONNSTRING);
SqlCommand Comm = new SqlCommand(Sql_Delete, Conn);
Comm.Parameters.Add("@AdminName", SqlDbType.VarChar).Value = AdminName;
Conn.Open();
Comm.ExecuteNonQuery();
Conn.Close();
}
大侠们请问又将如何改呢?