I have a column generated as int from datasource, how can I change it to dispay minutes and seconds? Is there a property in Gridview? For example. if I have value 70 to be shows as 01:10 or 1m 10s
CodePudding user response:
so, we have that colum with seconds - we want to convert to HH:mm:ss
So, we can use the row data bound event, and add this code:
protected void GHotels_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label txtSeconds = e.Row.FindControl("txtSeconds") as Label;
TimeSpan MySeconds = new TimeSpan(0,0,Convert.ToInt32(txtSeconds.Text));
txtSeconds.Text = MySeconds.ToString(@"hh\:mm\:ss");
}
}
And now we get: