4

有没有办法使绑定使用字符串格式?

    <asp:TemplateField HeaderText="Price" >
          <EditItemTemplate>

              <asp:TextBox ID="txtPrice" runat="server" Text='<%# String.Foramt("{0:#,###}",Bind("Price")) %>' />

          </EditItemTemplate>
4

2 回答 2

8

您可以使用以下允许您指定格式的重载:

<%# Bind("Price", "{0:#,###}") %>
于 2012-12-25T09:24:36.167 回答
2

您可以使用 DataBinder.Eval 的重载形式

<%# Eval("Price", "{0:#,###}") %>

使用绑定

<%= Bind("price", "{0:#,###}") %> 
于 2012-12-25T09:24:06.087 回答