I've stored the expiry date in MySQL DB and so I just wanted to display the date that's subtracted to Now() datetime in GridView.
I've seen a lot of answers regarding the subtraction of DateTime but the problem is, they all use Behind Code (C#). I don't know what to do after coding behind.
This is what I did to the GridView page...
<asp:TemplateField HeaderStyle-CssClass=" panel-heading text-center" HeaderText="DUE">
<ItemTemplate>
<asp:Label ID="countdown" CssClass="col-sm-10 text-center" runat="server" Text='<%# String.Format("{0} days left", Eval("countdown", "{0: dd/MM/yyyy}")) %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
Is there any way to display the subtracted DateTime value in GridView?
My idea is like this...
DateTime countdown_new = new DateTime();
countdown_new = dataReader.GetDateTime(dataReader.GetOrdinal("countdown"));
DateTime now = DateTime.Now;
int countdown = (int)(countdown_new - now).TotalDays;
string display = "Time left:" + countdown.Day + "Days";
I don't know what else to do...
So if possible, is there any way to just use the String.Format Text in GridView Label?