在Gridview标头中显示日期时间? [英] Display Datetime In Gridview Header?
本文介绍了在Gridview标头中显示日期时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在gridview标头中显示当前系统日期时间?我有5种会议方式(星期一至星期五),我想在今天的日期显示在第一列,而第二天显示在每一列.我试过了
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
<Columns>
<asp:BoundField HeaderText=" '<% Datetime.now.today.tostring %/>' "
</Columns>
推荐答案
为此,您可以使用gridview的RowDataBound事件.请参阅:
Hi,
For this you can use RowDataBound event of gridview. refer this:
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();
}
}
}
这可能对您有帮助.
祝一切顺利.
--Amit
This may help you.
All the best.
--Amit
这篇关于在Gridview标头中显示日期时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文