读书人

GridView1_RowCommand 有关问题提示

发布时间: 2011-12-24 23:03:24 作者: rapoo

GridView1_RowCommand 问题,提示“System.FormatException: 输入字符串的格式不正确”错误,请问哈如何解决,先谢谢了。。
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{

if (e.CommandName == "transfer ")
{
int index = Convert.ToInt32(e.CommandArgument);
GridView1.SelectedIndex = index;

DropDownList drpSort = GridView1.Rows[index].FindControl( "droSort ") as DropDownList;
Label lblId = GridView1.Rows[index].FindControl( "lblID ") as Label;
StringBuilder sbUpdate = new StringBuilder( "update CV_Friend set friendsort = ");
sbUpdate.Append(drpSort.SelectedValue);
sbUpdate.Append( " where Id = ");
sbUpdate.Append(lblId.Text);

Response.Write(sbUpdate.ToString());
Response.End();
try
{
SqlHelper.ExecuteNonQuery(WebConfig.WWWChinavalueDbConnectionString, CommandType.Text, sbUpdate.ToString());
}
catch
{
ShowClientMessegeBox( "转移失败! ");
}

}
}

[解决办法]
int index = Convert.ToInt32(e.CommandArgument);
===========================================
你的按钮列必须是ButtonField

读书人网 >asp.net

热点推荐