Set Date Visible condition in LinkButton Using ASP.NET C# Web Forms. I have a GridView. In GridView Template field using LinkButton. I want to match the condition batchdate less than and equal to then only LinkButton should visible true.
Below is my LinkButton‘s 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
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Use this:
In ASPX:
Visible='<%#GetVisible(Eval("BatchDate").ToString())%>'
And in the code behind:
public bool GetVisible(object value)
{
if (Convert.ToDateTime(value) <= DateTime.Now)
{
return true;
}
return false;
}
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0