Can i Make a Month Column Display May instead of 5

V

Vear

Hi,

I have a month column that is stored in SQL as an Int field. I would like to
change it after the stored procedure which means when it loads into the
DataGrid. I've tried several different things but none seem to work. I've
made the column a Template field but I can't figure out the Syntax to format
it to a long month.

Any help would be great.

Thanks.

Vear
 
P

Phillip Williams

<asp:TemplateColumn>
<ItemTemplate>
<asp:Label ID="lblMonth" runat="server"
Text='<%#ConvertNumToMonth(DataBinder.Eval(Container.DataItem,"MonthNumber"))
%>'></asp:Label>
</ItemTemplate>
</asp:TemplateColumn>

and in the CodeBehind:
Protected Function ConvertNumToMonth(ByVal iMonth As Integer)
Dim ret As String = "N/A"
If iMonth < 13 And iMonth > 0 Then
'this assumes that the date format according to your browser's
culture
'setting is MM/DD/YYYY
ret = DateTime.Parse(iMonth & "/01/2006").ToString("MMMM")
End If
Return ret
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top