|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Can i Make a Month Column Display May instead of 5Hi,
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 <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 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 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
CompositeControl and Toolbox
A socket operation was attempted to an unreachable network ID of web control changed Custom Panel How to upload files to a remote webserver using FileUpload ? MetaBuilders DualList control does not work in 2.0 Auto Download Serial Communication DropdownList fields in DetailView for sale: internetDotComs.com |
|||||||||||||||||||||||