Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

How do you display current system datetime in gridview header? I have 5 colunms (Mon - Fri) and I want to display in first column today's date and each column after display the next day. I have tried
ASP
<Columns>
<asp:BoundField HeaderText=" '<% Datetime.now.today.tostring %/>' "
</Columns>
Posted

1 solution

Hi,
For this you can use RowDataBound event of gridview. refer this:
C#
protected void GVSummaryTable_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.Cells.Count > 0)
    {
        //Translate header text
        if (e.Row.RowType == DataControlRowType.Header)
        {
            e.Row.Cells[0].Text = DateTime.Now.toString();
        }
    }
}

This may help you.
All the best.
--Amit
 
Share this answer
 
Comments
Vani Kulkarni 13-Jul-12 2:05am    
Correct! 5!
_Amy 13-Jul-12 2:05am    
Thank you Vani.!! :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900