gpt4 book ai didi

.net - 如何设置数据绑定(bind)文本框中文本的格式?

转载 作者:行者123 更新时间:2023-12-03 03:25:07 24 4
gpt4 key购买 nike

我的 ListView 具有以下 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>

我想格式化ExpectedAwardDateTextBox,以便它显示一个短的日期时间,但还没有找到一种方法来做到这一点,而不进入后面的代码。在项目模板中,我使用以下行来格式化标签中显示的日期:

<asp:Label ID="ExpectedAwardDateLabel" runat="server" Text='<%# String.Format("{0:M/d/yyyy}",Eval("ExpectedAwardDate")) %>' />

我想找到一个类似的方法来处理insertItemTemplate

最佳答案

您可以像这样使用 Bind() 重载:

<%# Bind("ExpectedAwardDate", "{0:M/d/yyyy}") %>

您的评估也一样:

<asp:Label ID="ExpectedAwardDateLabel" runat="server" 
Text='<%# Eval("ExpectedAwardDate","{0:M/d/yyyy}") %>' />

关于.net - 如何设置数据绑定(bind)文本框中文本的格式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2494932/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com