mazhar 124 mazhar 124 - 8 months ago 74
ASP.NET (C#) Question

Set Date Visible condition in LinkButton

Set Date Visible condition in Link Button Using ASP.NET C# Web forms. I have grid view in grid view Template field using link button. I want to match the condition batchdate less than and equal to then only link button should visible true.

Below is my link button code. I know wrote wrong visibility condition.

<asp:LinkButton ID="lnkbtn_ViewCan" runat="server"
Text="View Candidates" OnClick="lnkbtn_ViewCan_Click" Visible='<%# Eval("BatchDate").ToString() <= DateTime.Now %>' ></asp:LinkButton>

In database table BatchDate values is storing like below

2016-10-26 00:00:00.000


Use this:



And in the code behind:

public bool GetVisible(object value)
    if (Convert.ToDateTime(value) <= DateTime.Now)
        return true;
    return false;