I have a Temperature column in my GridView and want to retrieve the temperature value in decimal at RowDataBound. How do I do this? Thanks.
Try this:
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());
}
}
In case it errors out saying "Input String was not in a correct format" then take a look at this document