0

NextPrevおよびそれらの間のページ番号Repeater(のような)を使用してカスタム ページングを行うことは可能GridViewですか? 何かを見つけましたが、10ページしか機能しません。私が欲しいのは次のようなものです。ページングのためにGoogleのようなものです:

< 1 2 3 4 ... 15 >

Repeaterここで説明されている DataPager を使用できるように拡張することがわかりました: CodeProject: Extend Repeater to supportDataPager しかし、このエラーに直面SqlDataReaderしたときに使用すると:DataSource

Type 'System.Data.SqlClient.SqlDataReader' in Assembly 
    'System.Data, Version=4.0.0.0, Culture=neutral, 
    PublicKeyToken=b77a5c561934e089' is not marked as serializable.

それは私のコードです:

public bool ListBooksByCat(DataPagerRepeater.DataPagerRepeater repeater)
{
    List<string> selection = new List<string>();
    Dictionary<string, object> clause = new Dictionary<string, object>();
    clause.Add("IsValid", true);
    SqlDB myDb = new SqlDB(this.Connection);

    try
    {
        SqlDataReader reader = myDb.Retrive(this.TableName, selection, clause, "bookid", true);
        repeater.DataSource = reader;
        repeater.DataBind();
        reader.Close();
        return true;
    }
    catch (Exception e)
    {
        //logging errors
        return false;
    }
}

Note: DataPagerRepeater.DataPagerRepeater は、リンク先の記事に組み込まれています。

4

2 に答える 2

0

SqlReader にバインドするのではなく、データをオフラインにする DataTable またはその他のコレクションにコントロールをバインドする必要があります (DataReader は、バインド中は常に接続モードのままです)。SqlDataReader はリソース関連のオブジェクトであり、リソース関連のオブジェクトはクライアントに「渡す」ことができないため、このエラーが発生しています。

于 2013-08-11T12:29:53.883 に答える