首页 > 代码库 > 【Bootstrap3.0建站笔记三】AspNetPager分页,每一列都可排序
【Bootstrap3.0建站笔记三】AspNetPager分页,每一列都可排序
1、AspNetPager分页,实现每一列都可排序:
(1)、须要将默认排序字段放在HTML页面中。
(2)、排序字段放置为td节点的属性。
如图:
实现的效果图如:
HTML代码:
<div class="row"> <div class="col-lg-12 col-sm-12 col-xs-12 col-xxs-12"> <table class="table table-striped table-hover table-bordered bootstrap-datatable " id="DataTables_Table_0" > <thead> <tr><input type="hidden" id="defaultOrder" value="FirstDaijaDate" runat="server" /><!--默认排序--> <td class="sorting_asc" onclick="OrderBy(this)" sortf="FirstDaijaDate" text="首次代驾">首次代驾<input type="hidden" id="hidden_Orderby" value="FirstDaijaDate*sorting_desc" runat="server" /></td> <td class="sorting" onclick="OrderBy(this)" sortf="CustomerName" text="姓名">姓名</td> <td class="sorting" onclick="OrderBy(this)" sortf="CustomerPhone" text="联系方式">联系方式</td> <td class="sorting" onclick="OrderBy(this)" sortf="Attribution" text="归属地">归属地</td> <td class="sorting" onclick="OrderBy(this)" sortf="DaiJiaCount" text="代驾次数">代驾次数</td> <td class="sorting" onclick="OrderBy(this)" sortf="LastRechargeDate" text="最后充值">最后充值</td> <td class="sorting" onclick="OrderBy(this)" sortf="LastRechargeMoney" text="充值金额">充值金额</td> <td class="sorting" onclick="OrderBy(this)" sortf="TrackingState" text="跟踪状态">跟踪状态</td> <td class="sorting" onclick="OrderBy(this)" sortf="IsVisit" text="是否回訪">是否回訪</td> <td class="sorting" onclick="OrderBy(this)" sortf="IsVIP" text="是否VIP">是否VIP</td> <td class="sorting" onclick="OrderBy(this)" sortf="NextContactDate" text="再联系时间">再联系时间</td> <td class="sorting" onclick="OrderBy(this)" sortf="LastTrackingCustomerService" text="客服">客服</td> <td >操作</td> </tr> </thead> <tbody> <asp:Repeater ID="Repeater1" runat="server"> <ItemTemplate> <tr> <td ><%# Eval("FirstDaijaDate") %></td> <td ><%# Eval("CustomerName") %></td> <td ><%# Eval("CustomerPhone") %></td> <td ><%# Eval("Attribution") %></td> <td ><%# Eval("DaiJiaCount") %></td> <td ><%# Eval("LastRechargeDate").ToString()!="0001/1/1 0:00:00"?Eval("LastRechargeDate"):"" %></td> <td ><%# Eval("LastRechargeMoney") %></td> <td ><%# GetTrackingState(Eval("TrackingState").ToString().Trim())%></td> <td ><%# GetIsVisit(Eval("IsVisit")==null?"":Eval("IsVisit").ToString())%></td> <td ><%# Eval("IsVIP").ToString()=="true"?"是":"否"%></td> <td ><%# Eval("NextContactDate").ToString()!="0001/1/1 0:00:00"?Eval("NextContactDate"):"" %></td> <td ><%# Eval("LastTrackingCustomerService") %></td> <td> <div class="porpre"> <div class="input-group-btn" style="width: auto"> <a href="CustomerInformationDetails.aspx?Id=<%#Eval("Id") %>&phone=<%#Eval("CustomerPhone") %>&RecommendationNumber=<%#Eval("RecommendationNumber") %>&tabPage=CustomerDetail" class="btn btn-primary dropdown-toggle"> 查 看 </a> <a href="javascript:void(0);" onclick="btngroupClick(this,event)" class="btn btn-primary dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></a> </div> <div style="display: none;" class="pHide" id="pHide"> <ul> <li> <a href="CustomerInformationDetails.aspx?Id=<%#Eval("Id") %>&phone=<%#Eval("CustomerPhone") %>&RecommendationNumber=<%#Eval("RecommendationNumber") %>&tabPage=ViewAccount" class="btn btn-success ">查看子号</a> </li> <li> <a href="CustomerInformationDetails.aspx?Id=<%#Eval("Id") %>&phone=<%#Eval("CustomerPhone") %>&RecommendationNumber=<%#Eval("RecommendationNumber") %>&tabPage=Records" class="btn btn-info ">推荐记录</a> </li> <li> <a href="CustomerInformationDetails.aspx?Id=<%#Eval("Id") %>&phone=<%#Eval("CustomerPhone") %>&RecommendationNumber=<%#Eval("RecommendationNumber") %>&tabPage=FailureOrder" class="btn btn-warning ">未报订单</a> </li> <li> <a href="CustomerInformationDetails.aspx?Id=<%#Eval("Id") %>&phone=<%#Eval("CustomerPhone") %>&RecommendationNumber=<%#Eval("RecommendationNumber") %>&tabPage=DaijiaRecords" class="btn btn-danger ">代驾记录</a> </li> <li> <a href="CustomerInformationDetails.aspx?Id=<%#Eval("Id") %>&phone=<%#Eval("CustomerPhone") %>&RecommendationNumber=<%#Eval("RecommendationNumber") %>&tabPage=RechargeRecord" class="btn btn-primary ">充值记录</a> </li> <li class="ma"> <a href="CustomerInformationDetails.aspx?Id=<%#Eval("Id") %>&phone=<%#Eval("CustomerPhone") %>&RecommendationNumber=<%#Eval("RecommendationNumber") %>&tabPage=BillingRecord" class="btn btn-warning ">开票记录</a> </li> </ul> </div> </div> </td> </tr> </ItemTemplate> </asp:Repeater> </tbody> </table> </div> </div> <div class="row" style="margin-top: 15px;"> <div class="col-lg-12 col-sm-12 col-xs-12 col-xxs-12"> <div style='font-size:14px;'>共<label style="color:#20A8D8; font-size:14px;""><%=this.AspNetPager1.RecordCount %></label>条记录</div> </div> </div> <div class="row"> <div class="col-lg-12 col-sm-12 col-xs-12 col-xxs-12"> <webdiyer:AspNetPager ID="AspNetPager1" CssClass="paginator" CurrentPageButtonClass="cpb" OnPageChanged="AspNetPager1_PageChanged" runat="server" FirstPageText="首页" PageSize="5" LastPageText="尾页" NextPageText="← 下一页" PrevPageText="← 上一页" AlwaysShow="true" ShowPageIndexBox="Never" NumericButtonCount="10" CurrentPageButtonPosition="End" ShowFirstLast="false"> </webdiyer:AspNetPager> </div> </div>
JS代码:
//获取地址參数 function request(paras) { var url = location.href; var paraString = url.substring(url.indexOf("?") + 1, url.length).split("&"); var paraObj = {} for (i = 0; j = paraString[i]; i++) { paraObj[j.substring(0, j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=") + 1, j.length); } var returnValue = http://www.mamicode.com/paraObj[paras.toLowerCase()];>C#后台代码:
string OrderBySort = "FirstDaijaDate*sorting_desc"; if (Request.QueryString["OrderBySort"] != null && Request.QueryString["OrderBySort"] != "") { OrderBySort = Request.QueryString["OrderBySort"]; } this.hidden_Orderby.Value = http://www.mamicode.com/OrderBySort.Trim();>
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。