如何根据当前日期启用和禁用gridview复选框 [英] how can gridview checkbox enable and disable according to current date

查看:65
本文介绍了如何根据当前日期启用和禁用gridview复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何根据当前日期启用和禁用gridview复选框

how can gridview checkbox enable and disable according to current date

推荐答案

在gridview的RowDataBound事件中将今天的日期DateTime.Now或DateTime.Today与您的比较列字段值使用if条件使visiblitiy为您要隐藏的列的false





if(e.Row.RowType = = DataControlRowType.DataRow)

{

string todaydate = DateTime.Now.ToString();



Label Labelst =(Label)e.Row.FindControl(Label38);



if(Labelst.Text == todaydate)

{

Labelst.Visible = False;

}

}
In the RowDataBound event of gridview compare the today date DateTime.Now or DateTime.Today with your column fields values by using if condition make visiblitiy false for that column which you want to hide


if (e.Row.RowType == DataControlRowType.DataRow)
{
string todaydate = DateTime.Now.ToString();

Label Labelst = (Label)e.Row.FindControl("Label38");

if (Labelst.Text == todaydate)
{
Labelst.Visible=False;
}
}


这篇关于如何根据当前日期启用和禁用gridview复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆