asp:Repeater数据排序
2015-08-04 10:20
501 查看
<asp:Repeater ID="rptList" runat="server" OnItemCommand="rptList_ItemCommand" OnItemDataBound="rptList_ItemDataBound"> <HeaderTemplate> <table width="100%" border="0" cellspacing="0" cellpadding="0" class="msgtable"> <tr> <th width="100px"> <asp:LinkButton ID="CardAddNo" runat="server" CommandName="CardAddNo">单号</asp:LinkButton> </th> <th width="60px" align="center"> <asp:LinkButton ID="CardType" runat="server" CommandName="CardType">卡类型</asp:LinkButton> </th> <th width="70px"> <asp:LinkButton ID="CustomerNo" runat="server" CommandName="CustomerNo">卡号</asp:LinkButton> </th> <th width="60px" align="center"> <asp:LinkButton ID="Name" runat="server" CommandName="Name">姓名</asp:LinkButton> </th>
protected void rptList_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Header) { if (ViewState["id"] != null) { LinkButton lkbtnSort = (LinkButton)e.Item.FindControl(ViewState["id"].ToString().Trim()); lkbtnSort.ForeColor = System.Drawing.Color.Red; lkbtnSort.Text = ViewState["text"].ToString(); } } }
protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.Item.ItemType == ListItemType.Header) { LinkButton lkbtnSort = (LinkButton)e.Item.FindControl(e.CommandName.Trim()); if (ViewState[e.CommandName.Trim()] == null) { ViewState[e.CommandName.Trim()] = "ASC"; lkbtnSort.Text = lkbtnSort.Text + "▲"; } else { if (ViewState[e.CommandName.Trim()].ToString().Trim() == "ASC") { ViewState[e.CommandName.Trim()] = "DESC"; if (lkbtnSort.Text.IndexOf("▲") != -1) lkbtnSort.Text = lkbtnSort.Text.Replace("▲", "▼"); else lkbtnSort.Text = lkbtnSort.Text + "▼"; } else { ViewState[e.CommandName.Trim()] = "ASC"; if (lkbtnSort.Text.IndexOf("▼") != -1) lkbtnSort.Text = lkbtnSort.Text.Trim().Replace("▼", "▲"); else lkbtnSort.Text = lkbtnSort.Text + "▲"; } } ViewState["text"] = lkbtnSort.Text; ViewState["id"] = e.CommandName.Trim(); //数据绑定 }
相关文章推荐
- 数据排序谁最快(javascript中的Array.prototype.sort PK 快速排序)
- Python学习笔记_数据排序方法
- java_读取文件并对数据进行排序并写出
- Flex(mx:DataGrid)实现数据过滤显示
- django 数据排序
- PHP 实现冒泡法排序
- NOIP模拟题 River Path Word[排序][贪心][DP]
- Android对数据按照时间排序
- 仿今日头条频道管理
- 冒泡法与选择法对数据排序
- MySQL数据排序asc、desc
- NOIP2006 明明的随机数
- Android实现列表数据按名称排序、中英文混合排序
- ABP(现代ASP.NET样板开发框架)系列之18、ABP应用层——权限验证
- ASP.NET - 跳转页面
- 用Jasper report实现横向分栏报表
- 数独解算器(ASP.NET 2.0)
- 详解ASP.NET七大身份验证方式以及解决方案
- ASP.NET MVC 小牛之旅3:Routing——网址路由
- 维翔主机asp主机使用遇到的问题及解决方案总结