ListView中排序和分组(GroupTemplate)的使用实例演示
.aspx代码如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="8_Group_Sort.aspx.cs" Inherits="Group_Sort" %>
<!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>
<style type="text/css">
.item
{ padding:9px; border:1px solid silver; margin:5px;
float:left;
}
.item img
{ width:160px; height:120px;}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2>排序按钮 & 分组 & EmptyItemTemplate</h2>
<hr />
<asp:ListView ID="ListView1" runat="server" DataSourceID="AccessDataSource1"
ItemPlaceholderId="itemholder"
GroupPlaceholderID="groupholder"
GroupItemCount ="3"
>
<EmptyDataTemplate>
<p class ="item">SORRY,无相关数据</p>
</EmptyDataTemplate>
<LayoutTemplate>
<asp:Button ID="Button1" runat="server" Text="按mo_name排序"
CommandName="sort"
CommandArgument="mo_name" />
<asp:Button ID="Button2" runat="server" Text="按mo_siid排序"
CommandName="sort"
CommandArgument="mo_siid" />
<br />
<div runat="server" id="groupholder"></div>
</LayoutTemplate>
<GroupTemplate>
<div runat="server" id="itemholder"></div>
</GroupTemplate>
<GroupSeparatorTemplate>
<hr style ="clear:both;" />
</GroupSeparatorTemplate>
<EmptyItemTemplate>
<div class="item">
<p>空数据</p>
</div>
</EmptyItemTemplate>
<ItemTemplate>
<div class="item">
<img src=‘<%#Eval("imgsrc") %>‘ /><br />
<p><%#Eval("mo_name") %></p>
</div>
</ItemTemplate>
</asp:ListView>
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/mdb/EV.mdb" SelectCommand="SELECT TB_MONITOR.*, (img_folder +‘/‘ + img_fname) as imgsrc
FROM (TB_MONITOR INNER JOIN
T_IMGMNG ON TB_MONITOR.mo_imgid = T_IMGMNG.img_id)
">
</asp:AccessDataSource>
</div>
</form>
</body>
</html>
效果如下:
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。