模板中按锯的事件问题
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e){
if (e.CommandName == "modify")
{
int JobID = int.Parse(GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)].Values[0].ToString());
}
}
Gridview中添加一按钮,其CommandName为"modify",执行上面的语句没有问题,能正确获得JobID的值,但当把按钮转换为模板后,就出来这样的错误"输入字符串的格式不正确。"
请教高手如何解决
--------------------编程问答-------------------- 跟代码,检查 e.CommandArgument 的值及前台绑定. --------------------编程问答-------------------- 改成这样试试
其中 JobID 应为 GridView 主键列
----------------------------------------------
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
GridView1.SelectedIndex = Convert.ToInt32(e.CommandArgument);
if (e.CommandName == "modify")
{
int JobID = Convert.ToInt32(GridView1.SelectedValue)];
}
}
补充:.NET技术 , ASP.NET