您的位置:知识库 » .NET技术

ASP.NET 2.0数据教程之十一:基于数据的自定义格式化

作者: xwang  来源: 博客园  发布时间: 2008-10-14 13:52  阅读: 5266 次  推荐: 0   原文链接   [收藏]  

系列文章导航:

ASP.NET 2.0数据教程之一:创建一个数据访问层

ASP.NET 2.0数据教程之二:创建一个业务逻辑层

ASP.NET 2.0数据教程之三:母板页和站点导航

ASP.NET 2.0数据教程之四:使用ObjectDataSource展现数据

ASP.NET 2.0数据教程之五:声明参数

ASP.NET 2.0数据教程之六:编程设置ObjectDataSource的参数值

ASP.NET 2.0数据教程之七:使用DropDownList过滤的主/从报表

ASP.NET 2.0数据教程之八:使用两个DropDownList过滤的主/从报表

ASP.NET 2.0数据教程之九:跨页面的主/从报表

ASP.NET 2.0数据教程之十:使用 GridView 和DetailView实现的主/从报表

ASP.NET 2.0数据教程之十一:基于数据的自定义格式化

ASP.NET 2.0数据教程之十二:在GridView控件中使用TemplateField


Step 7:GridView中显示产品信息

添加一个GridViewFormView的下方,设置IDHighlightCheapProducts.我们之前已经设置了一个ObjectDataSource来获取产品数据,现在我们绑定GridViewObjectDataSource. 之后,编辑GridView的绑定列包含产品的name.categorie,price属性。完成之后GridView的代码将会是:

<asp:GridView ID="HighlightCheapProducts" runat="server" AutoGenerateColumns="False"

    DataKeyNames="ProductID" DataSourceID="ObjectDataSource1" EnableViewState="False">

    <Columns>

        <asp:BoundField DataField="ProductName" HeaderText="Product" SortExpression="ProductName" />

        <asp:BoundField DataField="CategoryName" HeaderText="Category" ReadOnly="True" SortExpression="CategoryName" />

        <asp:BoundField DataField="UnitPrice" DataFormatString="{0:c}" HeaderText="Price"

            HtmlEncode="False" SortExpression="UnitPrice" />

    </Columns>

</asp:GridView>

 

 

图九显示浏览器查看的结果


9: GridView显示产品的name, category, price

0
0

.NET技术热门文章

    .NET技术最新文章

      最新新闻

        热门新闻