boundcolumn 最主要的功能是利用label 来显示数据源中的一个字段内容,其使用语法如下所示:
<asp:boundcolumn
datafield="datasourcefield"
dataformatstring="formatstring"
footertext="footertext"
headerimageurl="url"
headertext="headertext"
readonly="true | false"
sortfield="datasourcefieldtosortby"
visible="true | false"
footerstyle-property="value"
headerstyle-property="value"
itemstyle-property="value"
/>
其中除了共同基础属性以及样式对象外,常用的属性如下表所示:

下列程序代码片段以boundcolumn 来显示字段内容:
<asp:datagrid id="dga" allowpaging="true" pagesize="5"
onpageindexchanged="dga_pagechg" runat="server"
pagerstyle-mode="numericpages" bordercolor="#808080"
headerstyle-font-names="courier new"
headerstyle-backcolor="#d1dceb"
autogeneratecolumns="false">
<property name="columns">
<asp:boundcolumn
headertext="姓名"
headerstyle-font-bold="true"
headerstyle-horizontalalign="center"
datafield="username"/>
<asp:boundcolumn
headertext="电话"
headerstyle-font-bold="true"
headerstyle-horizontalalign="center"
datafield="usertel"/>
<asp:boundcolumn
headertext="住址"
headerstyle-font-bold="true"
headerstyle-horizontalalign="center"
datafield="useradd"/>
</property>
</asp:datagrid>
