在使用GridView的时候,删除事件中,写的如下代码,但编译时提示
System.Web.UI.WebControls.GridViewDeletedEventArgs”并不包含“RowIndex”的定义 //删除 protected void GridView1_RowDeleted(object sender, GridViewDeletedEventArgs e)
{
int affectRow = 0;
String str = "server=localhost;database=DB;uid=sa;pwd=sa";
SqlConnection sqlcon = new SqlConnection(str);
String str1 = "update company set Status=-1 where Unid='" + GridView1.DataKeys[e.RowIndex].Value.ToString() +"'";
SqlCommand cmd = new SqlCommand(str1,sqlcon);
try
{
sqlcon.Open();
affectRow = cmd.ExecuteNonQuery();
}
catch (SqlException ex)
{
affectRow = 0;
throw new ApplicationException(ex.Message);
}
finally
{
sqlcon.Close();
}
if (affectRow > 0 )
{
BindSort();
}
else
{
Response.Redirect("www.sohu.com");
}
}
System.Web.UI.WebControls.GridViewDeletedEventArgs”并不包含“RowIndex”的定义 //删除 protected void GridView1_RowDeleted(object sender, GridViewDeletedEventArgs e)
{
int affectRow = 0;
String str = "server=localhost;database=DB;uid=sa;pwd=sa";
SqlConnection sqlcon = new SqlConnection(str);
String str1 = "update company set Status=-1 where Unid='" + GridView1.DataKeys[e.RowIndex].Value.ToString() +"'";
SqlCommand cmd = new SqlCommand(str1,sqlcon);
try
{
sqlcon.Open();
affectRow = cmd.ExecuteNonQuery();
}
catch (SqlException ex)
{
affectRow = 0;
throw new ApplicationException(ex.Message);
}
finally
{
sqlcon.Close();
}
if (affectRow > 0 )
{
BindSort();
}
else
{
Response.Redirect("www.sohu.com");
}
}
换成
GridView1_RowDeleting事件
“System.Web.UI.WebControls.GridViewDeletedEventArgs”并不包含“RowIndex”的定义 还有1楼的直接找key是什么意思?