How can I format the text in a databound TextBox?
Posted
by Abe Miessler
on Stack Overflow
See other posts from Stack Overflow
or by Abe Miessler
Published on 2010-03-22T18:57:16Z
Indexed on
2010/03/22
19:01 UTC
Read the original article
Hit count: 328
I have ListView that has the following EditItemTemplate:
<EditItemTemplate>
<tr style="">
<td>
<asp:LinkButton ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
<asp:LinkButton ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
</td>
<td>
<asp:TextBox ID="FundingSource1TextBox" runat="server" Text='<%# Bind("FundingSource1") %>' />
</td>
<td>
<asp:TextBox ID="CashTextBox" runat="server" Text='<%# Bind("Cash") %>' />
</td>
<td>
<asp:TextBox ID="InKindTextBox" runat="server" Text='<%# Bind("InKind") %>' />
</td>
<td>
<asp:TextBox ID="StatusTextBox" runat="server" Text='<%# Bind("Status") %>' />
</td>
<td>
<asp:TextBox ID="ExpectedAwardDateTextBox" runat="server" Text='<%# Bind("ExpectedAwardDate","{0:MM/dd/yyyy}) %>' onclientclick="datepicker()" />
</td>
</tr>
</EditItemTemplate>
I would like to format the "ExpectedAwardDateTextBox" so it shows a short date time but haven't found a way to do this without going into the code behind. In the Item template I have the following line to format the date that appears in the lable:
<asp:Label ID="ExpectedAwardDateLabel" runat="server" Text='<%# String.Format("{0:M/d/yyyy}",Eval("ExpectedAwardDate")) %>' />
And I would like to find a similar method to do with the insertItemTemplate.
© Stack Overflow or respective owner