按以下步骤
来源:互联网 发布:计算机编程可以自学吗 编辑:程序博客网 时间:2024/05/05 10:26
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
2.选择程序中的Microsoft .NET FrameWork
3.选择Documention
4.选择Index选项卡
5.输入“DataFormatString property”
6.双出出现的第一个关键词。
7.以下出现内容:
.NET Framework Class Library
BoundColumn.DataFormatString PropertySee Also
BoundColumn Class | BoundColumn Members | System.Web.UI.WebControls Namespace | String.Empty | DataGrid | Formatting Overview
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP
Language
C#
C++
JScript
Visual Basic
Show All
This is preliminary documentation and subject to change.
Send feedback on this topic.
Gets or sets the string that specifies the display format for items in the column.
[Visual Basic]
Overridable Public Property DataFormatString As String
[C#]
public virtual string DataFormatString {get; set;}
[C++]
public: __property virtual String* get_DataFormatString();
public: __property virtual void set_DataFormatString(String*);
[JScript]
public function get DataFormatString() : String;
public function set DataFormatString(String);
Property Value
A formatting string that specifies the display format of items in the column. The default value is String.Empty.
Remarks
Use the DataFormatString property to provide a custom format for the items in the column.
The data format string consists of two parts, separated by a colon, in the form {A:Bxx}. For example, the formatting string, {0:D2}, would format the cell to display a number with two decimal places.
Note The entire string must be enclosed in curly braces to denote that it is a format string and not a literal string. Any text outside the curly braces is displayed as literal text.
The value before the colon ( A in the general example) specifies the parameter index in a zero-based list of parameters.
Note This value can only be set to 0 because there is only one value in each cell.
The character after the colon ( B in the general example) specifies the format to display the value in. The following table lists the common formats.
Format Character Description
C Displays numeric values in currency format.
D Displays numeric values in decimal format.
E Displays numeric values in scientific (exponential) format.
F Displays numeric values in fixed format.
G Displays numeric values in general format.
N Displays numeric values in number format.
X Displays numeric values in hexadecimal format.
Note The format character is not case-sensitive, except for X, which displays the hexadecimal characters in the case specified.
The value after the format character ( xx in the general example) specifies the number of significant digits or decimal places to display the value in.
For more information on formatting strings, see Formatting Overview.
Example
[Visual Basic, C#] The following example demonstrates how to use the DataFormatString property to specify currency format for the column that displays the prices in of the DataGrid control.
[C#]
<%@ Import Namespace="System.Data" %>
<html>
<script language="C#" runat="server">
ICollection CreateDataSource()
{
DataTable dt = new DataTable();
DataRow dr;
dt.Columns.Add(new DataColumn("IntegerValue", typeof(Int32)));
dt.Columns.Add(new DataColumn("StringValue", typeof(string)));
dt.Columns.Add(new DataColumn("CurrencyValue", typeof(double)));
for (int i = 0; i < 9; i++)
{
dr = dt.NewRow();
dr[0] = i;
dr[1] = "Item " + i.ToString();
dr[2] = 1.23 * (i + 1);
dt.Rows.Add(dr);
}
DataView dv = new DataView(dt);
return dv;
}
void Page_Load(Object sender, EventArgs e)
{
if (!IsPostBack)
{
// need to load this data only once
ItemsGrid.DataSource= CreateDataSource();
ItemsGrid.DataBind();
}
}
</script>
<body>
<form runat=server>
<h3><font face="Verdana">BoundColumn Example</font></h3>
<b>Product List</b>
<asp:DataGrid id="ItemsGrid"
BorderColor="black"
BorderWidth="1"
CellPadding="3"
AutoGenerateColumns="false"
runat="server">
<HeaderStyle BackColor="#00aaaa">
</HeaderStyle>
<Columns>
<asp:BoundColumn
HeaderText="Number"
DataField="IntegerValue">
</asp:BoundColumn>
<asp:BoundColumn
HeaderText="Description"
DataField="StringValue">
</asp:BoundColumn>
<asp:BoundColumn
HeaderText="Price"
DataField="CurrencyValue"
DataFormatString="{0:c}">
</asp:BoundColumn>
</Columns>
</asp:DataGrid>
</form>
</body>
</html>
[Visual Basic]
<%@ Import Namespace="System.Data" %>
<html>
<script language="VB" runat="server">
Function CreateDataSource() As ICollection
Dim dt As New DataTable()
Dim dr As DataRow
dt.Columns.Add(New DataColumn("IntegerValue", GetType(Int32)))
dt.Columns.Add(New DataColumn("StringValue", GetType(String)))
dt.Columns.Add(New DataColumn("CurrencyValue", GetType(Double)))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 1.23 *(i + 1)
dt.Rows.Add(dr)
Next i
Dim dv As New DataView(dt)
Return dv
End Function 'CreateDataSource
Sub Page_Load(sender As Object, e As EventArgs)
If Not IsPostBack Then
' need to load this data only once
ItemsGrid.DataSource = CreateDataSource()
ItemsGrid.DataBind()
End If
End Sub 'Page_Load
</script>
<body>
<form runat=server>
<h3><font face="Verdana">BoundColumn Example</font></h3>
<b>Product List</b>
<asp:DataGrid id="ItemsGrid"
BorderColor="black"
BorderWidth="1"
CellPadding="3"
AutoGenerateColumns="false"
runat="server">
<HeaderStyle BackColor="#00aaaa">
</HeaderStyle>
<Columns>
<asp:BoundColumn
HeaderText="Number"
DataField="IntegerValue">
</asp:BoundColumn>
<asp:BoundColumn
HeaderText="Description"
DataField="StringValue">
</asp:BoundColumn>
<asp:BoundColumn
HeaderText="Price"
DataField="CurrencyValue"
DataFormatString="{0:c}">
</asp:BoundColumn>
</Columns>
</asp:DataGrid>
</form>
</body>
</html>
[C++, JScript] No example is available in C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP
See Also
BoundColumn Class | BoundColumn Members | System.Web.UI.WebControls Namespace | String.Empty | DataGrid | Formatting Ove
下步骤';return true">
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
1.打开开始菜单2.选择程序中的Microsoft .NET FrameWork
3.选择Documention
4.选择Index选项卡
5.输入“DataFormatString property”
6.双出出现的第一个关键词。
7.以下出现内容:
.NET Framework Class Library
BoundColumn.DataFormatString PropertySee Also
BoundColumn Class | BoundColumn Members | System.Web.UI.WebControls Namespace | String.Empty | DataGrid | Formatting Overview
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP
Language
C#
C++
JScript
Visual Basic
Show All
This is preliminary documentation and subject to change.
Send feedback on this topic.
Gets or sets the string that specifies the display format for items in the column.
[Visual Basic]
Overridable Public Property DataFormatString As String
[C#]
public virtual string DataFormatString {get; set;}
[C++]
public: __property virtual String* get_DataFormatString();
public: __property virtual void set_DataFormatString(String*);
[JScript]
public function get DataFormatString() : String;
public function set DataFormatString(String);
Property Value
A formatting string that specifies the display format of items in the column. The default value is String.Empty.
Remarks
Use the DataFormatString property to provide a custom format for the items in the column.
The data format string consists of two parts, separated by a colon, in the form {A:Bxx}. For example, the formatting string, {0:D2}, would format the cell to display a number with two decimal places.
Note The entire string must be enclosed in curly braces to denote that it is a format string and not a literal string. Any text outside the curly braces is displayed as literal text.
The value before the colon ( A in the general example) specifies the parameter index in a zero-based list of parameters.
Note This value can only be set to 0 because there is only one value in each cell.
The character after the colon ( B in the general example) specifies the format to display the value in. The following table lists the common formats.
Format Character Description
C Displays numeric values in currency format.
D Displays numeric values in decimal format.
E Displays numeric values in scientific (exponential) format.
F Displays numeric values in fixed format.
G Displays numeric values in general format.
N Displays numeric values in number format.
X Displays numeric values in hexadecimal format.
Note The format character is not case-sensitive, except for X, which displays the hexadecimal characters in the case specified.
The value after the format character ( xx in the general example) specifies the number of significant digits or decimal places to display the value in.
For more information on formatting strings, see Formatting Overview.
Example
[Visual Basic, C#] The following example demonstrates how to use the DataFormatString property to specify currency format for the column that displays the prices in of the DataGrid control.
[C#]
<%@ Import Namespace="System.Data" %>
<html>
<script language="C#" runat="server">
ICollection CreateDataSource()
{
DataTable dt = new DataTable();
DataRow dr;
dt.Columns.Add(new DataColumn("IntegerValue", typeof(Int32)));
dt.Columns.Add(new DataColumn("StringValue", typeof(string)));
dt.Columns.Add(new DataColumn("CurrencyValue", typeof(double)));
for (int i = 0; i < 9; i++)
{
dr = dt.NewRow();
dr[0] = i;
dr[1] = "Item " + i.ToString();
dr[2] = 1.23 * (i + 1);
dt.Rows.Add(dr);
}
DataView dv = new DataView(dt);
return dv;
}
void Page_Load(Object sender, EventArgs e)
{
if (!IsPostBack)
{
// need to load this data only once
ItemsGrid.DataSource= CreateDataSource();
ItemsGrid.DataBind();
}
}
</script>
<body>
<form runat=server>
<h3><font face="Verdana">BoundColumn Example</font></h3>
<b>Product List</b>
<asp:DataGrid id="ItemsGrid"
BorderColor="black"
BorderWidth="1"
CellPadding="3"
AutoGenerateColumns="false"
runat="server">
<HeaderStyle BackColor="#00aaaa">
</HeaderStyle>
<Columns>
<asp:BoundColumn
HeaderText="Number"
DataField="IntegerValue">
</asp:BoundColumn>
<asp:BoundColumn
HeaderText="Description"
DataField="StringValue">
</asp:BoundColumn>
<asp:BoundColumn
HeaderText="Price"
DataField="CurrencyValue"
DataFormatString="{0:c}">
</asp:BoundColumn>
</Columns>
</asp:DataGrid>
</form>
</body>
</html>
[Visual Basic]
<%@ Import Namespace="System.Data" %>
<html>
<script language="VB" runat="server">
Function CreateDataSource() As ICollection
Dim dt As New DataTable()
Dim dr As DataRow
dt.Columns.Add(New DataColumn("IntegerValue", GetType(Int32)))
dt.Columns.Add(New DataColumn("StringValue", GetType(String)))
dt.Columns.Add(New DataColumn("CurrencyValue", GetType(Double)))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 1.23 *(i + 1)
dt.Rows.Add(dr)
Next i
Dim dv As New DataView(dt)
Return dv
End Function 'CreateDataSource
Sub Page_Load(sender As Object, e As EventArgs)
If Not IsPostBack Then
' need to load this data only once
ItemsGrid.DataSource = CreateDataSource()
ItemsGrid.DataBind()
End If
End Sub 'Page_Load
</script>
<body>
<form runat=server>
<h3><font face="Verdana">BoundColumn Example</font></h3>
<b>Product List</b>
<asp:DataGrid id="ItemsGrid"
BorderColor="black"
BorderWidth="1"
CellPadding="3"
AutoGenerateColumns="false"
runat="server">
<HeaderStyle BackColor="#00aaaa">
</HeaderStyle>
<Columns>
<asp:BoundColumn
HeaderText="Number"
DataField="IntegerValue">
</asp:BoundColumn>
<asp:BoundColumn
HeaderText="Description"
DataField="StringValue">
</asp:BoundColumn>
<asp:BoundColumn
HeaderText="Price"
DataField="CurrencyValue"
DataFormatString="{0:c}">
</asp:BoundColumn>
</Columns>
</asp:DataGrid>
</form>
</body>
</html>
[C++, JScript] No example is available in C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP
See Also
BoundColumn Class | BoundColumn Members | System.Web.UI.WebControls Namespace | String.Empty | DataGrid | Formatting Ove
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- 按以下步骤
- 心跳检测需要以下步骤
- 按以下步骤添加供 Virtual PC 使用的 Microsoft Loopback Adapter:
- 系统正常关机要经历以下步骤
- 文档共享分为以下几个步骤
- 创建共享内存分以下几个步骤
- 动态创建Fastreport分以下几个步骤:
- 创建共享内存分以下几个步骤
- 正规风险投资机构投资程序都会经历以下步骤:
- W3C规范的正式出台需要经过以下七个步骤
- 一切咨询过程都可以概括为以下五个步骤
- 在ubuntu10.10下我按照以下步骤配置tftp
- (51)重写equals()方法一般需要按照以下步骤书写
- Windows XP IIS 500内部错误 解决方案(HTTP 500内部服务器错误) 按以下步骤进行: 1.在控制面板->管理工具->服务 中确认"Distributed Transactio
- 要在vs2005中实现最基本的打印文本基本上需要以下几个步骤
- Ubuntu 10.04 及以下版本安装 Windows 里的中文字体库的步骤
- 在java中类装载器把一个类装入JVM,经过以下步骤:
- 嵌入式 基于OpenSSL的程序都要遵循以下几个步骤
- 附:创建 Windows XP 图标
- JIT编译
- Microsoft 中间语言(MSIL)
- ASP.NET中使用Caching
- C#---非对称加密的一个程序
- 按以下步骤
- vb.net视觉--vb.net代码实例
- Paging Database Results in ASP.NET (Prt1)(转载:http:
- 转转:ASP.NET数据库编程 (1)
- ASP.NET数据库编程 (2)
- VB.NET窗体操作技巧两则
- ASP.NET相关问题14问
- VB技巧:VB.NET中的变量范围差异
- Microsoft .NET框架糅合各种编程语言,开创Web新时代