asp.net---ListView的简单使用

来源:互联网 发布:复共轭矩阵与厄米矩阵 编辑:程序博客网 时间:2024/04/30 09:10


.aspx代码如下:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ListView练习.aspx.cs" Inherits="ListView练习" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">    <title></title></head><body>    <form id="form1" runat="server">    <div>        <asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1" ItemPlaceholderID="holder"><%--ItemPlaceholderID="holder"重要告诉Item占位符的ID--%>        <LayoutTemplate><%--1布局模板必要--%>        <p>员工信息表</p>        <p>TEST</p>        <p runat="server" id="holder"></p><%--id="holder"告诉ItemTemplate插入到哪个位置--%>        <p>TEST</p>        </LayoutTemplate>        <ItemTemplate><%--2数据模板必要--%>        <p> <%#Eval("姓名")%> <%#Eval("年龄")%></p><%--姓名和年龄是字段名--%>                </ItemTemplate>          </asp:ListView>        <asp:SqlDataSource ID="SqlDataSource1" runat="server"             ConnectionString="<%$ ConnectionStrings:userinfoConnectionString %>"             SelectCommand="SELECT * FROM [员工信息表]"></asp:SqlDataSource>    </div>    </form></body></html>

效果如下:


0 0
原创粉丝点击