protected void gvcolors_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
int esal = (int)DataBinder.Eval(e.Row.DataItem, "Emp_Sal");
if (esal > 12000)
{
e.Row.ForeColor = System.Drawing.Color.Blue;
e.Row.BackColor = System.Drawing.Color.LightPink;
e.Row.Font.Italic = true;
}
}
}
指定的转换无效。我正在采用 Emp_Sal , int 数据类型..但它显示异常..它是否正确。请帮助我..
代替
int esal = (int)DataBinder.Eval(e.Row.DataItem, "Emp_Sal");
你可能想尝试
int esal = (int)e.Row.Cells[1].Text; //index of the Emp_Sal column
您应该使用 int.tryparse。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)