Is it possible to have custom paging with Next and Prev and page numbers between them for Repeater
(like GridView
)? I found something but it works for 10 pages only.
What I want is like this, something like google does for paging:
< 1 2 3 4 ... 15 >
I found out extending Repeater
let me use DataPager, explained here: CodeProject: Extend Repeater to support DataPager
But when I use SqlDataReader
as DataSource
I face this error:
Type 'System.Data.SqlClient.SqlDataReader' in Assembly
'System.Data, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' is not marked as serializable.
It's my code:
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 is built in linked article.