急,这是什么错误呀?新手上路
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
showuser();
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
string Id;
int RowIndex;
RowIndex = Convert.ToInt32(e.CommandArgument.ToString());
string StrConn = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;
if (e.CommandName == "Delinfo")
{
Id = GridView1.Rows[RowIndex].Cells[0].Text;
string Sql = "delete from tb_User where UserId = " + Id;
ExecPro.ExecPro.ExecuteNonQuery(StrConn, CommandType.Text, Sql);
showuser();
{
Response.Write("<script language=javascript>alert('删除成功!');historyback();</script>");
}
}
if (e.CommandName == "btnupdate")
{
Id = GridView1.Rows[RowIndex].Cells[0].Text;
Response.Redirect("04-01-update.aspx?ID="+Id);
}
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Button But = (Button)e.Row.Cells[5].FindControl("Btndelete");
But.CommandArgument = e.Row.RowIndex.ToString(); //定义删除按钮的命令参数
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
Button But = (Button)e.Row.Cells[4].FindControl("btnupdate");
But.CommandArgument = e.Row.RowIndex.ToString();
}
}
为什么做了一个gridview的分页,就出现了 RowIndex = Convert.ToInt32(e.CommandArgument.ToString());的错误。
输入字符串的格式不正确。
这是什么原因