ObjectDataSource.EnablePaging プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ObjectDataSource.EnablePaging プロパティの意味・解説 

ObjectDataSource.EnablePaging プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

データ ソース コントロール取得したデータ セット使用するページングサポートしているかどうかを示す値を取得または設定します

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文構文

Dim instance As ObjectDataSource
Dim value As Boolean

value = instance.EnablePaging

instance.EnablePaging = value
public bool EnablePaging { get;
 set; }
public:
property bool EnablePaging {
    bool get ();
    void set (bool value);
}
/** @property */
public boolean get_EnablePaging ()

/** @property */
public void set_EnablePaging (boolean value)
public function get EnablePaging
 () : boolean

public function set EnablePaging
 (value : boolean)

プロパティ
データ ソース コントロール取得したデータ使用するページングサポートしている場合trueそれ以外場合false

解説解説

ObjectDataSource コントロールによるページングは、ObjectDataSourceEnablePaging、StartRowIndexParameterName、MaximumRowsParameterName、SelectCountMethod の各プロパティ設定し適切なパラメータビジネス オブジェクト選択メソッド定義することによって処理されます。EnablePaging プロパティtrue設定すると、SelectParameters コレクションに、要求され最初の行と要求された行数に対応する 2 つパラメータ追加されます。この 2 つパラメータには、StartRowIndexParameterName プロパティMaximumRowsParameterName プロパティ定義された名前が付けられます。Select メソッドは、指定されインデックス位置で始まる要求された行数を返しますデータは、ページ サイズによって均等に分割されない場合があるため、最後ページには行がほとんど含まれていない場合あります。したがって要求された行数は、実際に返される最大行数です。

関連付けられたデータ バインド コントロールページング有効になっている場合データ バインド コントロールは、必要とされる開始インデックス行数使用してSelect メソッド呼び出します。また、SelectCountMethod プロパティ設定されている場合データ バインド コントロールは、ページャ コントロール表示する前にこのメソッド呼び出します。たとえば、GridView コントロールページ サイズが 5 の状態でページング有効になっており、SelectCountMethod プロパティ指定されメソッド20返す場合、4 ページ分だけページャ表示されます。

EnablePaging プロパティは、ObjectDataSourceView オブジェクトの EnablePaging プロパティに処理を代行させます

使用例使用例

このセクションには、2 つコード例含まれています。1 つ目のコードでは、ページング有効にする型を実装する方法示します2 つ目のコード例では、ObjectDataSource クラスインスタンス作成しプロパティ設定する方法示します

ページング有効にする型を実装する方法次のコード例示しますPagingData.Select メソッドは、startRowIndex および maximumRows2 つパラメータ受け取りますまた、PagingData クラスは、データ内の行の総数返す SelectCount という名前のメソッド定義しますPagingData クラスコード次に示します

Imports System
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls

Namespace Samples.AspNet.VB


    Public Class PagingData
        Public Sub New()
        End Sub

        Shared table As DataTable

        Private Function CreateData() As
 DataTable
            table = New DataTable()
            table.Columns.Add("Name", GetType(String))
            table.Columns.Add("Number", GetType(Integer))
            Return table
        End Function


        Public Function SelectMethod(ByVal
 startRowIndex As Integer, ByVal
 maximumRows As Integer) As DataTable

            CreateData()
            Dim current As Integer
            For i As Integer
 = 0 To maximumRows - 1
                current = i + startRowIndex
                table.Rows.Add(New Object()
 {"Number" + current.ToString(), current})
            Next
            Return table
        End Function


        Public Function SelectCount() As
 Integer

            Return 20
        End Function

        Public Function Insert(ByVal
 newRecord As NewData) As Integer

            table.Rows.Add(New Object() {newRecord.Name,
 newRecord.Number})
            Return 1
        End Function

    End Class

    Public Class NewData

        Private nameValue As String
        Private numberValue As Integer

        Public Property Name() As
 String
            Get
                Return nameValue
            End Get
            Set(ByVal value As
 String)
                nameValue = value
            End Set
        End Property

        Public Property Number() As
 Integer
            Get
                Return numberValue
            End Get
            Set(ByVal value As
 Integer)
                numberValue = value
            End Set
        End Property
    End Class

End Namespace
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace Samples.AspNet.CS
{

    public class PagingData
    {

        public PagingData()
        {

        }

        static DataTable table;

        private DataTable CreateData()
        {
            table = new DataTable();
            table.Columns.Add("Name", typeof(string));
            table.Columns.Add("Number", typeof(int));
            return table;
        }

        public DataTable SelectMethod(int startRowIndex,
 int maximumRows)
        {
            CreateData();
            int current;
            for (int i = 0; i < maximumRows;
 i++)
            {
                current = i + startRowIndex;
                table.Rows.Add(new object[] { "Number"
 + current.ToString(), current });
            }
            return table;
        }

        public int SelectCount()
        {
            return 20;
        }

        public int Insert(NewData newRecord)
        {
            table.Rows.Add(new object[] { newRecord.Name, newRecord.Number
 });
            return 1;
        }
    }


    public class NewData
    {
    private string nameValue;
    private int numberValue;

    public string Name
    {
        get { return nameValue; }
        set { nameValue = value; }
    }

    public int Number
    {
        get { return numberValue; }
        set { numberValue = value; }
    }

    }
}

ObjectDataSource クラスインスタンス作成しページングに関する次のプロパティ設定する方法次のコード例示します

MaximumRowsParameterName プロパティStartRowIndexParameterName プロパティの値は、それぞれ maximumRows および startRowIndex という既定値として残されます。

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<script runat="server">

</script>

<html  >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="GridView1" 
            runat="server" 
            AllowPaging="True" 
            DataSourceID="ObjectDataSource1"
            PageSize="5">
        </asp:GridView>
        <asp:ObjectDataSource 
            ID="ObjectDataSource1" 
            runat="server" 
            EnablePaging="True" 
            SelectCountMethod="SelectCount"
            SelectMethod="SelectMethod" 
            TypeName="Samples.AspNet.VB.PagingData">
        </asp:ObjectDataSource>
    </div>
    </form>
</body>
</html>
<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<script runat="server">

</script>

<html  >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="GridView1" 
            runat="server" 
            AllowPaging="True" 
            DataSourceID="ObjectDataSource1"
            PageSize="5">
        </asp:GridView>
        <asp:ObjectDataSource 
            ID="ObjectDataSource1" 
            runat="server" 
            EnablePaging="True" 
            SelectCountMethod="SelectCount"
            SelectMethod="SelectMethod" 
            TypeName="Samples.AspNet.CS.PagingData">
        </asp:ObjectDataSource>
    </div>
    </form>
</body>
</html>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ObjectDataSource クラス
ObjectDataSource メンバ
System.Web.UI.WebControls 名前空間
StartRowIndexParameterName
MaximumRowsParameterName
CanPage



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「ObjectDataSource.EnablePaging プロパティ」の関連用語

ObjectDataSource.EnablePaging プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ObjectDataSource.EnablePaging プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS