ListView中排序和分组(GroupTemplate)的使用实例演示

时间:2022-11-11 12:56:18


ListView中排序和分组(GroupTemplate)的使用实例演示

ListView中排序和分组(GroupTemplate)的使用实例演示

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 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" ></div>
</LayoutTemplate>

<GroupTemplate>
<div runat="server" ></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>

效果如下:

ListView中排序和分组(GroupTemplate)的使用实例演示