Eyal
Eyal

Reputation: 4763

Bind to textbox with string.format

Is there a way to make the binding work with string format?

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

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

          </EditItemTemplate>

Upvotes: 4

Views: 12682

Answers (2)

Adil
Adil

Reputation: 148110

You can use overload form of DataBinder.Eval

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

Using Bind

<%= Bind("price", "{0:#,###}") %> 

Upvotes: 2

Darin Dimitrov
Darin Dimitrov

Reputation: 1038710

You could use the following overload which allows you to specify the format:

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

Upvotes: 8

Related Questions