Details - DataFormatString property for formatting fields
DetailsViewFormattingFieldsExample.aspx
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>asp.net DetailsView example: how to use DataFormatString property for formatting fields</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Navy">DetailsView Formatting Fields Example</h2>
<asp:SqlDataSource
ID="SqlDataSource1"
runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT TOP 8 ProductID, ProductName, UnitPrice FROM Products"
>
</asp:SqlDataSource>
<asp:DetailsView
ID="DetailsView1"
runat="server"
DataSourceID="SqlDataSource1"
ForeColor="AliceBlue"
BackColor="DodgerBlue"
BorderColor="LightSkyBlue"
AutoGenerateRows="false"
AllowPaging="true"
>
<Fields>
<asp:BoundField HeaderText="Product ID" DataField="ProductID" />
<asp:BoundField HeaderText="Product Name" DataField="ProductName" />
<asp:BoundField HeaderText="UnitPrice" DataField="UnitPrice" DataFormatString="{0:C}" />
</Fields>
<HeaderTemplate>
<b>Product Details</b>
</HeaderTemplate>
<HeaderStyle BackColor="DarkBlue" />
</asp:DetailsView>
</div>
</form>
</body>
</html>