zoukankan      html  css  js  c++  java
  • 使用【表格式】数据绑定控件

    “表格式”数据绑定控件可以一次显示一组数据项,有 五种。

    它们分为 两类:一类是一次显示多个数据项;另一类是一次显示单个数据项。

    • GridView——在HTML表格中显示一组数据记录。可以 显示、排序、分页、选择、编辑数据。
    • DataList——在HTML表格中显示一组数据记录。它在一行中显示多条记录
    • Repeater——使用模板显示一组数据记录。它不会自动呈现为一个HTML表格。
    • DetailView——在HTML表格中显示一个数据项。它能够分页、编辑、添加数据
    • FormView——使用模板显示一个数据项。它可以使用模板来进行窗体布局

    <%@ Page Language="VB" %>

    <!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 runat="server">

    <title>Show Tabular Databound Controls</title>

    <style type="text/css">
    .floater
    {
    float:left;
    border:solid 1px black;
    padding:5px;
    margin:5px;
    }
    </style>
    </head>
    <body>
    <form id="form1" runat="server">

    <div class=floater>
    <h3>GridView</h3>
    <asp:GridView DataSourceID=srcmovies runat=server></asp:GridView>
    </div>

    <div class=floater>
    <h3>DataList</h3><%--需要自定义模板--%>
    <asp:DataList ID="dl1" datasourceid=srcMovies RepeatColumns=2 runat=server>
    <ItemTemplate >
    <b><%#Eval("Title")%></b>
    <i>directed by</i>
    <%#Eval("director")%>
    </ItemTemplate>
    </asp:DataList>
    </div>
    <div class=floater>
    <h3>Repeater</h3><%--需要定义模板--%>
    <asp:Repeater ID=r1 runat=server DataSourceID=srcmovies >
    <ItemTemplate>
    <b><%#Eval("title")%></b>
    <i>导演是</i>
    <%#Eval("director")%><br />
    </ItemTemplate>
    </asp:Repeater>
    </div>

    <div class=floater>
    <h3>DetailsView</h3><%--每次显示一项数据记录--%>
    <asp:DetailsView ID=dv1 DataSourceID=srcmovies runat=server AllowPaging=true>
    </asp:DetailsView>
    </div>

    <div class=floater>
    <h3>FormView</h3>
    <asp:FormView ID=fv1 DataSourceID=srcmovies runat=server AllowPaging=true>
    <ItemTemplate>
    <%# Eval("title") %> directed by <%#Eval("director")%>
    </ItemTemplate>
    </asp:FormView>
    </div>
    <asp:SqlDataSource ID="srcMovies" ConnectionString="data source=.\SqlExpress;integrated security=true;user instance=true;attachDBFileName=|DataDirectory|mydatabase.mdf" SelectCommand="select title,director from movies" runat=server></asp:SqlDataSource>
    </form> </body>
    </html>
  • 相关阅读:
    BeforeFieldInit解析(zz)
    自定义控件
    How to make Office VBA code interact with a VSTO applicationlevel addin
    总结
    IL汇编语言程序设计目录
    zz如何精简用户界面
    volatile关键字的作用(zz)
    外企面试基本涵盖了所有问题(拿得别人的,很有用)
    Excel 2007 There was a problem sending the command to the program
    数据库技巧
  • 原文地址:https://www.cnblogs.com/lizunicon/p/2431066.html
Copyright © 2011-2022 走看看