控件中国网现已改版,您看到的是老版本网站的镜像,系统正在为您跳转到新网站首页,请稍候.......
中国最专业的商业控件资讯网产品咨询电话:023-67870900 023-67871946
产品咨询EMAIL:SALES@COMPONENTCN.COM

Repeater自定义分页 + 排序 + 全选删除

作者:佚名 出处:互联网 2010年12月20日 阅读:

页面代码:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RepeaterPagingSortingDelete.aspx.cs" Inherits="RepeaterPagingSortingDelete" %>

<!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>RepeaterPagingSortingDelete</title>
    <script language="javascript" type="text/javascript">
        function chooseAll(sender)
        {
            var inputs = document.all.tags("INPUT");
            // 遍历页面上所有的 input 
            for (var i = 0; i < inputs.length; i++) 
            {       
                    //如果此input元素的类型为checkbox,并且其id中包含chkSelect
                    if (inputs[i].type == "checkbox" && inputs[i].id.indexOf("chkSelect") >= 0)
                    {
                        //设置此复选框的checked与全选复选框相同
                        inputs[i].checked = document.getElementById(sender).checked;
                        inputs[i].onclick();
                    } 
            }
        }
        
        function highLightSelected(chkSelect)
        { 
            if (chkSelect.checked) 
                chkSelect.parentElement.parentElement.style.backgroundColor='#CCCCFF'; 
            else 
                chkSelect.parentElement.parentElement.style.backgroundColor='white'; 
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:LinkButton id="lbtnFirst" runat="server" CommandName="First" OnCommand="lbtnPage_Command">|<</asp:LinkButton>  
        <asp:LinkButton id="lbtnPrevious" runat="server" CommandName="Previous" OnCommand="lbtnPage_Command"><<</asp:LinkButton>  
        <asp:Label id="lblMessage" runat="server" />  
        <asp:LinkButton id="lbtnNext" runat="server" CommandName="Next" OnCommand="lbtnPage_Command">>></asp:LinkButton>  
        <asp:LinkButton id="lbtnLast" runat="server" CommandName="Last" OnCommand="lbtnPage_Command">>|</asp:LinkButton>  
        转到第<asp:DropDownList ID="dropPage" runat="server" AutoPostBack="True" OnSelectedIndexChanged="dropPage_SelectedIndexChanged"></asp:DropDownList>页        
        <asp:Repeater ID="rptProducts" runat="server" 
            onitemcreated="rptProducts_ItemCreated" 
            onitemdatabound="rptProducts_ItemDataBound">
            <HeaderTemplate>
                <table border="1">
                <tr>
                    <td id="tdAll" runat="server"><asp:CheckBox ID="chkAll" runat="server" /></td>
                    <td id="tdProductID" runat="server"><asp:LinkButton ID="lbtnProductID" runat="server" Text="ProductID" CommandName="ProductID" OnCommand="lbtnSort_Command"></asp:LinkButton><asp:Label ID="lblHeadProductID" runat="server" Visible="false"></asp:Label></td>
                    <td id="tdProductName" runat="server"><asp:LinkButton ID="lbtnProductName" runat="server" Text="ProductName" CommandName="ProductName" OnCommand="lbtnSort_Command"></asp:LinkButton><asp:Label ID="lblProductName" runat="server" Visible="false"></asp:Label></td>
                    <td id="tdSupplierID" runat="server"><asp:LinkButton ID="lbtnSupplierID" runat="server" Text="SupplierID" CommandName="SupplierID" OnCommand="lbtnSort_Command"></asp:LinkButton><asp:Label ID="lblSupplierID" runat="server" Visible="false"></asp:Label></td>
                    <td id="tdCategoryID" runat="server"><asp:LinkButton ID="lbtnCategoryID" runat="server" Text="CategoryID" CommandName="CategoryID" OnCommand="lbtnSort_Command"></asp:LinkButton><asp:Label ID="lblCategoryID" runat="server" Visible="false"></asp:Label></td>
                    <td id="tdQuantityPerUnit" runat="server"><asp:LinkButton ID="lbtnQuantityPerUnit" runat="server" Text="QuantityPerUnit" CommandName="QuantityPerUnit" OnCommand="lbtnSort_Command"></asp:LinkButton><asp:Label ID="lblQuantityPerUnit" runat="server" Visible="false"></asp:Label></td>
                    <td id="tdUnitPrice" runat="server"><asp:LinkButton ID="lbtnUnitPrice" runat="server" Text="UnitPrice" CommandName="UnitPrice" OnCommand="lbtnSort_Command"></asp:LinkButton><asp:Label ID="lblUnitPrice" runat="server" Visible="false"></asp:Label></td>
                    <td id="tdUnitsInStock" runat="server"><asp:LinkButton ID="lbtnUnitsInStock" runat="server" Text="UnitsInStock" CommandName="UnitsInStock" OnCommand="lbtnSort_Command"></asp:LinkButton><asp:Label ID="lblUnitsInStock" runat="server" Visible="false"></asp:Label></td>
                    <td id="tdUnitsOnOrder" runat="server"><asp:LinkButton ID="lbtnUnitsOnOrder" runat="server" Text="UnitsOnOrder" CommandName="UnitsOnOrder" OnCommand="lbtnSort_Command"></asp:LinkButton><asp:Label ID="lblUnitsOnOrder" runat="server" Visible="false"></asp:Label></td>
                    <td id="tdReorderLevel" runat="server"><asp:LinkButton ID="lbtnReorderLevel" runat="server" Text="ReorderLevel" CommandName="ReorderLevel" OnCommand="lbtnSort_Command"></asp:LinkButton><asp:Label ID="lblReorderLevel" runat="server" Visible="false"></asp:Label></td>
                    <td id="tdDiscontinued" runat="server"><asp:LinkButton ID="lbtnDiscontinued" runat="server" Text="Discontinued" CommandName="Discontinued" OnCommand="lbtnSort_Command"></asp:LinkButton><asp:Label ID="lblDiscontinued" runat="server" Visible="false"></asp:Label></td>
                </tr>
            </HeaderTemplate>
            <ItemTemplate>
                <tr>
                    <td id="tdSelect" runat="server"><asp:CheckBox ID="chkSelect" runat="server" /></td>
                    <td><asp:Label ID="lblProductID" runat="server" Text='<%# Eval("ProductID") %>'></asp:Label></td>
                    <td><asp:Label ID="lblProductName" runat="server" Text='<%# Eval("ProductName") %>'></asp:Label></td>
                    <td><asp:Label ID="lblSupplierID" runat="server" Text='<%# Eval("SupplierID") %>'></asp:Label></td>
                    <td><asp:Label ID="lblCategoryID" runat="server" Text='<%# Eval("CategoryID") %>'></asp:Label></td>
                    <td><asp:Label ID="lblQuantityPerUnit" runat="server" Text='<%# Eval("QuantityPerUnit") %>'></asp:Label></td>
                    <td><asp:Label ID="lblUnitPrice" runat="server" Text='<%# Eval("UnitPrice") %>'></asp:Label></td>
                    <td><asp:Label ID="lblUnitsInStock" runat="server" Text='<%# Eval("UnitsInStock") %>'></asp:Label></td>
                    <td><asp:Label ID="lblUnitsOnOrder" runat="server" Text='<%# Eval("UnitsOnOrder") %>'></asp:Label></td>
                    <td><asp:Label ID="lblReorderLevel" runat="server" Text='<%# Eval("ReorderLevel") %>'></asp:Label></td>
                    <td><asp:CheckBox ID="chkDiscontinued" runat="server" Checked='<%# Eval("Discontinued") %>' Enabled="false" /></td>
                </tr>
            </ItemTemplate>
            <FooterTemplate>
                </table>
            </FooterTemplate>
        </asp:Repeater>
        <asp:Button ID="btnDelete" runat="server" Text="删除" onclick="btnDelete_Click" />
    </div>
    </form>
</body>
</html>

热推产品

  • ActiveReport... 强大的.NET报表设计、浏览、打印、转换控件,可以同时用于WindowsForms谀坔攀戀Forms平台下......
  • AnyChart AnyChart使你可以创建出绚丽的交互式的Flash和HTML5的图表和仪表控件。可以用于仪表盘的创......
首页 | 新闻中心 | 产品中心 | 技术文档 | 友情连接 | 关于磐岩 | 技术支持中心 | 联系我们 | 帮助中心 Copyright-2006 ComponentCN.com all rights reserved.重庆磐岩科技有限公司(控件中国网) 版权所有 电话:023 - 67870900 传真:023 - 67870270 产品咨询:sales@componentcn.com 渝ICP备12000264号 法律顾问:元炳律师事务所 重庆市江北区塔坪36号维丰创意绿苑A座28-5 邮编:400020
在线客服
在线客服系统
在线客服
在线客服系统