Marius Vasile

Marius Vasile

  • 585
  • 1.8k
  • 136.7k

Convert int Date to full name in Eval

Sep 15 2024 8:47 AM

I get month as integer from a Stored Procedure and I am some how forced to have it as integer but in View I want to display month name

<asp:TextBox ID="TextBox1" class="form-control" runat="server" Text='<%#(Eval("Month"))%>' Style="font-size: 9px;" />

I tried with 

<asp:TextBox ID="TextBox1" class="form-control" runat="server" Text='<%#Convert.ToDateTime(Eval("Month")).ToString("MMMM")%>' Style="font-size: 9px;" />

but I get error

Invalid cast from 'Int32' to 'DateTime'.

How it should be done?


Answers (1)