按以下步骤

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 Overview

时间: 2024-08-01 16:51:27

按以下步骤的相关文章

5步骤了解后期的基本

  对于现在数码时代的摄影来说,Photoshop不是万能的,但缺少Photoshop也是万万不能的!风光摄影不是一个记录过程,做到的不能仅仅是"拍到了",我觉得应该是一个创作的过程,特别是在后期处理的过程中,创作意味更浓. 对于刚刚接触摄影后期的朋友来说,如下的五个基本方法,很简单,但很见效,会让你的摄影作品焕然一新. 写在前面 我理解的风光摄影,不仅仅是一种记录,更多的时候是一种情感抒发.同样的景色,不同的人带着不同的心情去看,就是不同的景色,所以我的风光摄影我更愿意定义为情感风光

从图片上传的三个步骤来分析其中的交互过程

传统的图片上传交互很简单:一个文件域要求用户选择图片文件,一个提交按钮(如下图). 这种方式有很多缺点,比如选择图片后看不到预览,一次只能选择一张图,上传过程看不到进度.当然也有它自身的优点:html本身的表单控件,代码简单,上传不易出错,适合低速网络环境.现在富媒体横行的时代,用户需要长传大量图片,这种传统表单的方式上传图片显然已经跟不上时代的需求,基于 flash.html5的新型上传方式被广泛的应用. 我们从上传图片前.上传中.上传后三个步骤来分析其中的交互过程. 上传前 上传图片前一般可

win7开机出现“致命错误C0000034,正在更新操作XXX 共XXX个”的解决步骤

  win7系统开机出现问题属于常见故障问题之一,这不有位用户说win7系统开机的时候出现"致命错误C0000034,正在更新操作XXX 共102964个0000000000000000.cdf-ms"这是怎么回事呢?可能是电脑在更新时,中途因为某种原因而中断(如强制关机,断电,意外重启等),再次开机就会出现这种情况.本文教程为大家讲解详细解决步骤. 解决步骤如下: 1. 手动重启电脑,一直按F8,选择选项 "启动修复": 2.修复启动框---取消---"

可配置语法分析器开发纪事(三点五) 生成下推自动机的具体步骤

刚刚发了上一篇文章之后就发现状态机画错了.虽然LiveWriter有打开博客并修改文章的功能,不过为了让我留下一个教训,我还是决定发一篇勘误.这个教训就是,作分析的时候不要随便"跳步",该一步一步来就一步一步来.其实人呢,就是很容易忘掉以前的教训的了.第一个告诉我不能这么干的人其实是小学三年级的数学老师.当时我因为懒得写字,所以计算应用题的时候省了几步,被批评了. 故事就从状态机开始.文法我就不重复了,见上一篇文章.现在我们从状态机开始.第一个状态机是直接从文法变过来的: 开发纪事(三

Virtualbox下实现Ubuntu虚拟机和win7主机文件共享(很简单,亲自试用,按此步骤一般都会成功)

最近做一个操作系统实验,第一个实验即是实现Ubantu虚拟机与主机之间的共享. 本例用的是VirtualBox虚拟机,若使用Vmware WorkStation虚拟机则方法与下文介绍略有不同,但基本相似. 没有使用网上说的什么下载增强包等等的方法,经过多次测试才设置成功,现在把具体方法给大家说一下 实现共享最关键的一个步骤即是虚拟机与宿主机之间使用不同IP地址,否则会IP地址冲突,然后使用桥接的方式将他们进行连接.(在学校实验室里,由于每台计算机都是在一个局域网之中,并且学校用的是XP系统,所以

分页步骤和过程简单的说说吧

问题描述 分页步骤和过程简单的说说吧 面试要答的题目,谁知道可以说一下吗?帮忙简单的说说呗,可以吗,谢谢 解决方案 是操作系统分页吗? 如下: 利用键盘输入本模拟系统的物理块的大小,作业的页表中的块号:完成逻辑地址转换成相应的物理地址的过程. 1.建立一张位示图,用来模拟内存的分配情况,利用随机数产生一组0和1的数对应内存的使用情况. 2.输入块(页)的大小,通过模拟位示图为本作业分配内存空间建立相应的页表(长度不定): 3.录入逻辑地址转换成相应的物理地址 4.扩充页表,变成请求式的二维页表(

编译错误-freeglut安装问题:已按照网上步骤进行,编译freeglut项目失败

问题描述 freeglut安装问题:已按照网上步骤进行,编译freeglut项目失败 1.生成 2.编译 问题描述细节:编译方式中debug.release和静态配置全部使用过,都是undefined symbols的问题.另外,我读了freeglut项目中的说明文档,有这么一个提示:Windows Questions======= =========(1) My linking fails due to undefined symbols. What libraries do I need t

插入U盘无反应的处理步骤

  插入U盘无反应的处理步骤          你是否有过插U盘后没有任何反应,根据经验,一般按如下步骤进行处理就可以解决了: 1.换台机子试一下是不是U盘的问题. 2.驱动安装问题. 3.win2003不会自动给移动设备分配盘符,在设备管理器里看看. 4.若是前置接口,有可能线路未接通,插到主板后面看看. 5. 在Windows资源管理器中,进入到"系统盘:WINDOWSinf"目录,找到名为"Usbstor.pnf"的文件,右键点击该文件,在弹出菜 单中选择&q

Word基本操作步骤

一.给文档添加页脚"河南省中小学教师计算机考试卷",居中排列.将自己的考号.姓名设置为页眉 步骤: 1.单击视图 /页眉和页脚 2.在页眉处输入自己的考号.姓名,在页脚处输入"河南省中小学教师计算机考试卷" 3.选中"河南省中小学教师计算机考试卷", 单击格式 /段落, 在对齐方式中选"居中", 单击确定 最后在文挡的中间双击鼠标左键. 二.将要编辑的文本另起一页显示 步骤: 1.定位光标: 将光标定在将要编辑的文本的开始处

三分钟、五步骤,轻松搞定视频直播

直播系统的搭建   图一 直播系统搭建的五大步骤 典型的直播系统的搭建分为五个步骤:第一步需要先申请一个域名:第二步需要进行配置直播:第三步在配置直播后,获取推流地址:第四步,进行推流:最后一步播放.下面来具体分析下每一步的操作细节: 图二 域名申请 域名申请:在阿里云官网上可以通过外网完成域名申请,同时还可以进行实名认证.但域名申请不一定要通过阿里云实现,很多的第三方服务商同样可以提供相同的服务.   图三 服务开通 当域名申请成功后,使用者就可以开通直播服务,通过阿里云,使用者可以一次开通六