我的GridView中有一个Temperature列,想要在RowDataBound中检索十进制的温度值。我该怎么做呢?感谢。
答案 0 :(得分:2)
试试这个:
void GridView_RowDataBound(Object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
// say temparature field in column 3
decimal temp = decimal.Parse(e.Row.Cells[2].Text.ToString());
}
}
如果出现“输入字符串格式不正确”的错误,请查看此文档