⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 default.aspx

📁 gridview的使用大全,包括所有常见的功能 开发环境为asp.net2.0
💻 ASPX
字号:
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:CheckBox ID="cbxAll" runat="server" AutoPostBack="True" OnCheckedChanged="cbxAll_CheckedChanged"
            Style="z-index: 100; left: 352px; position: absolute; top: 8px" Text="全选" />
        <br />
        <asp:Button ID="btnAdd" runat="server" OnClick="btnAdd_Click" Style="z-index: 101;
            left: 56px; position: absolute; top: 200px" Text="添加" />
        <asp:Label ID="lblName" runat="server" Style="z-index: 102; left: 8px; position: absolute;
            top: 120px" Text="用户名"></asp:Label>
        <asp:TextBox ID="txtName" runat="server" Style="z-index: 103; left: 88px; position: absolute;
            top: 120px"></asp:TextBox>
        <asp:Button ID="btnReset" runat="server" OnClick="btnReset_Click" Style="z-index: 111;
            left: 120px; position: absolute; top: 200px" Text="重置" />
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
            ForeColor="#333333" GridLines="None" OnRowCancelingEdit="GridView1_RowCancelingEdit"
            OnRowDeleting="GridView1_RowDeleting" OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating" AllowPaging="True" CellSpacing="1" HorizontalAlign="Center" PageSize="5" OnPageIndexChanging="GridView1_PageIndexChanging" Height="59px">
            <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
            <Columns>
                <asp:TemplateField HeaderText="选定" ShowHeader="False">
                    <EditItemTemplate>
                        <asp:CheckBox ID="CheckBox1" runat="server" />
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:CheckBox ID="cbx" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="id" HeaderText="编号" />
                <asp:BoundField DataField="userID" HeaderText="用户名" />
                <asp:CommandField ShowSelectButton="True" />
                <asp:CommandField HeaderText="修改" ShowEditButton="True" CancelText="&lt;div id=&quot;de&quot; onclick=&quot;JavaScript:return confirm('确定取消编辑吗?')&quot;&gt;取消&lt;/div&gt;" ShowInsertButton="True" NewText="" UpdateText="&lt;div id=&quot;de&quot; onclick=&quot;JavaScript:return confirm('确定更新当前记录吗?')&quot;&gt;更新&lt;/div&gt;" />
                <asp:CommandField ShowDeleteButton="True" CancelText="" DeleteText="&lt;div id=&quot;de&quot; onclick=&quot;JavaScript:return confirm('确定删除吗?')&quot;&gt;删除&lt;/div&gt;" />
            </Columns>
            <RowStyle BackColor="#E3EAEB" />
            <EditRowStyle BackColor="#7C6F57" />
            <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
            <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
            <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="White" />
            <PagerSettings PageButtonCount="6" Mode="NumericFirstLast" />
        </asp:GridView>
        <asp:Button ID="btnFirst" runat="server" Style="z-index: 105; left: 308px; position: absolute;
            top: 270px" Text="首页" Height="24px" OnClick="Button1_Click" Width="90px" /><asp:Button ID="btnLast" runat="server" Style="z-index: 106; left: 574px; position: absolute;
            top: 270px" Text="尾页" OnClick="Button2_Click" Width="90px" />
        <asp:Button ID="btnMove" runat="server" Style="z-index: 107; left: 486px; position: absolute;
            top: 270px" Text="下一页" Height="24px" OnClick="Button3_Click" Width="90px" />
        <asp:Button ID="btnPro" runat="server" Style="z-index: 108; left: 398px; position: absolute;
            top: 270px" Text="上一页" Height="24px" OnClick="Button4_Click" Width="90px" />
        &nbsp;
        <asp:Label ID="Label2" runat="server" Style="z-index: 109; left: 352px; position: absolute;
            top: 248px" Text="Label"></asp:Label>
        <asp:Button ID="btnDelALL" runat="server" OnClick="btnDelALL_Click" Style="z-index: 110;
            left: 416px; position: absolute; top: 8px" Text="批量删除" Enabled="False" Visible="False" />
    
    </div>
    </form>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -