If the textboxes reside in a DataGrid, DataList or Repeater, then the best way to do this is to use Web Server Control Templates (see ms-help://MS.VSCC.2003/MS.MSDNQTR.2003OCT.1033/vbcon/html/vbconwebformscontrolstemplates.htm in VS.NET's help system). By creating a template, you can specify how each item is to be displayed. For the particular grid items, you can specify an item template that looks something like this:
<ItemTemplate>Of course, if you have just a textbox you want to fill with a data-bound expression, you can simply do the following:
<asp:Label id=Label1 runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "Field", "{0:C}")%>'> </asp:Label> </ItemTemplate>
<asp:TextBox id=TextBox1 runat="server"
Text='<%# DataBinder.Eval(DataSet1, "Field", "{0:C}") %>'>
</asp:TextBox>
In both types of data binding, the third parameter to DataBinder.Eval is the format specification, in this case, using {0:C} means we want the value held in the DataSet's "Field" column to be displayed as currency.
This was first published in May 2004