how to format a textbox in an item template

Last post 01-24-2008 1:18 AM by aspnetdev2000. 3 replies.

Sort Posts:

  • how to format a textbox in an item template

    01-24-2008, 12:17 AM

    for boundfield in a gridview I use this:

    <asp:BoundField DataField="DOB" DataFormatString="{0:dd/MM/yyyy}" HeaderText="DOB" SortExpression="DOB" >
                    <ItemStyle Wrap="False" />
                </asp:BoundField>

    But for an item template which has a label I use the following:

    <ItemTemplate>
               <asp:Label ID="lblDOB" runat="server" Text='<%# Bind("DOB") %>'></asp:Label>
    </ItemTemplate>

    Where do I set the formatting of the label in the above template?

    Thx in advance

    aspnetdev2000
  • Re: how to format a textbox in an item template

    01-24-2008, 12:43 AM
    Answer
    • Loading...
    • e_screw
    • Joined on 10-20-2004, 1:22 PM
    • Women, Guitar, Russia, Billiards, Nature, .NET
    • Posts 3,852

    <ItemTemplate>
               <asp:Label ID="lblDOB" runat="server" Text='<%# Bind("DOB", "{0:dd/MM/yyyy}") %>'></asp:Label>
    </ItemTemplate>

    Thanks

    -Mark post(s) as "Answer" that helped you

    Mark post(s) as "Answer" that helped you

    Electronic Screw
    Website||Blog||Dub@i.net
  • Re: how to format a textbox in an item template

    01-24-2008, 12:45 AM

    aspnetdev2000:
    <asp:Label ID="lblDOB" runat="server" Text='<%# Bind("DOB") %>'></asp:Label>
     

    did you try as..

    <asp:Label ID="lblDOB" runat="server" Text='<%# string.Format("{0:dd/MM/yyyy}",Bind("DOB")) %>'></asp:Label>

    or

    <asp:Label ID="lblDOB" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"DOB","{0:dd/MM/yyyy}") %>'></asp:Label>

    assuming that DOB is a DATETIME field... 

     

    Thanx,
    [KaushaL] || BloG || Profile

  • Re: how to format a textbox in an item template

    01-24-2008, 1:18 AM

    thx

    aspnetdev2000
Page 1 of 1 (4 items)
Microsoft Communities
Page view counter