So, basically, my data is extracted from the database, for which I want it to be displayed in gridview. Unfortunately, the days of the week are stored as integers, so Monday is 0, and Tuesday is 1, etc.
Basically, how can I change the data since it is output so that it converts the number to the correct day of the week.
I have a grid view as follows, and at the moment I have it configured using onrowdatabound:
<asp:GridView ID="GridView1" runat="server" AllowSorting="True"
AutoGenerateColumns="False" DataSourceID="SqlDataSource2" Width="721px"
onrowdatabound="GridView_RowDataBound"
>
Then the code for GridView_RowDataBound:
protected void GridView_RowDataBound(Object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
}
}
, . - . , . , , , !
!
protected void GridView1_RowDataBound(Object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
int days = (int)GridView1.Rows[e.Row.RowIndex].Cell[2].Text;
if (days == 0) GridView1.Rows[e.Row.RowIndex].Cell[2].Text = "Monday";
if (days == 1) GridView1.Rows[e.Row.RowIndex].Cell[2].Text = "Tuesday";
if (days == 1) GridView1.Rows[e.Row.RowIndex].Cell[2].Text = "Wednesday";
if (days == 1) GridView1.Rows[e.Row.RowIndex].Cell[2].Text = "Thursday";
if (days == 1) GridView1.Rows[e.Row.RowIndex].Cell[2].Text = "Friday";
}
}