如何根据当前日期隐藏gridview中的编辑按钮 [英] Ho w to hide edit button in gridview based on current date

查看:108
本文介绍了如何根据当前日期隐藏gridview中的编辑按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

如果gridview中的某个日期列小于当前日期,我需要隐藏我的编辑按钮。但是它隐藏了所有列中的编辑按钮。任何帮助都会非常感谢。谢谢。



我的尝试:



Hi all,
I need to hide my edit button if one of the date column in gridview is less than the current date .However it is hiding the edit button in all columns .Any help will be really appreciated .Thanks in advance .

What I have tried:

 if (e.Row.RowType == DataControlRowType.DataRow)
            {
DateTime myDate = (DateTime)DataBinder.Eval(e.Row.DataItem, "appoinmentDate");
                string apintdate=DataBinder.Eval(e.Row.DataItem, "appoinmentDate").ToString();
                if (DateTime.Now <= myDate)
                {
                    Button btnEdit = (Button)e.Row.FindControl("ibut_Edit");
                    btnEdit.Visible = false;
                }
}

推荐答案

你好,



查看此链接;我已经开始相信CompareTo方法。



此外,考虑删除/删除不需要的按钮而不是让它们不可见。



顺便说一下,行:

Hi there,

Take a look at this link; I have come to trust the CompareTo method.

Moreover, consider removing/deleting undesired buttons instead of just making them invisible.

By the way, the line:
string apintdate=DataBinder.Eval(e.Row.DataItem, "appoinmentDate").ToString();

似乎没有参与该代码。如果之后使用,则忽略此注释。



干杯!

does not seem to play a part in that code. If it is used afterwards, then ignore this note.

Cheers!


这篇关于如何根据当前日期隐藏gridview中的编辑按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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