Home All Groups Group Topic Archive Search About

Can i Make a Month Column Display May instead of 5

Author
19 Apr 2006 3:10 AM
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

Author
19 Apr 2006 5:15 AM
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


Show quoteHide quote
"Vear" wrote:

> 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
Author
19 Apr 2006 5:23 AM
Vear
Worked perfectly!

Thanks once again Phillip! 3 for 3

Vear

Show quoteHide quote
"Phillip Williams" wrote:

> <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
>
>
> --
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
>
> "Vear" wrote:
>
> > 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
Author
19 Apr 2006 5:25 AM
Phillip Williams
You are welcome.
Show quoteHide quote
"Vear" wrote:

> Worked perfectly!
>
> Thanks once again Phillip! 3 for 3
>
> Vear
>
> "Phillip Williams" wrote:
>
> > <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
> >
> >
> > --
> > HTH,
> > Phillip Williams
> > http://www.societopia.net
> > http://www.webswapp.com
> >
> >
> > "Vear" wrote:
> >
> > > 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