0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【C#】【SQL Server】Web FormにPageSize属性を付与する

Posted at

Web FormアプリにPageSize属性を付与する場合の注意点です。

✅ポイント

PageSize は AllowPaging="true" を指定しないと意味がありません。

AllowPaging を忘れずに設定してください

sample2.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="sample2.aspx.cs" Inherits="WebApplicationWebForm.sample2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <!--検証1-->
    <table>
        <thead>
            <tr>
                <th>従業員ID</th>
                <th>所属部署</th>
                <th>所属課</th>
                <th>役職</th>
                <th>従業員名</th>
                <th>性別</th>
                <th>IPaddress</th>
                <th>IPaddressの割り振り</th>
            </tr>
        </thead>
        <tbody>
            <form id="form2" runat="server">
            <asp:GridView ID="GridViewClass" runat="server" PageIndex=0 AllowPaging="true" PageSize="20" AutoGenerateColumns="false" AllowSorting="true" OnSorting="GridViewClass_Sorting" CssClass="table" OnRowDataBound="GridViewDataModelBind">
                <Columns>
                    <asp:BoundField DataField="employeeId" HeaderText="従業員ID" SortExpression="employeeId" />
                    <asp:BoundField DataField="department" HeaderText="所属部署" SortExpression="department" />
                    <asp:BoundField DataField="section" HeaderText="所属課" SortExpression="section" />
                    <asp:BoundField DataField="jobclass" HeaderText="役職" SortExpression="jobclass" />
                    <asp:BoundField DataField="name" HeaderText="従業員名" SortExpression="name" />
                    <asp:BoundField DataField="sex" HeaderText="性別" SortExpression="sex" />
                    <asp:BoundField DataField="ipaddress" HeaderText="IPaddress" SortExpression="ipaddress" />
                    <asp:BoundField DataField="ipaddressalocation" HeaderText="IPaddressの割り振り" SortExpression="ipaddressalocation" />
                </Columns>
            </asp:GridView>
            </form>
        </tbody>
    </table>
</body>
</html>

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?