Paging with Datalist using pager control
Download pager controlĀ ASPnetPagerV2_8.dll
Bind Datalist:
string MulRowCol = Convert.ToString(PagerV2_1.PageSize);
if (Request.QueryString[“pageindex”] != null)
{
PagerV2_1.CurrentIndex = Convert.ToInt32(Request.QueryString[“pageindex”]);
PagerV2_2.CurrentIndex = Convert.ToInt32(Request.QueryString[“pageindex”]);
}
MatrixRow = Convert.ToInt32(MulRowCol);
PagerV2_1.Visible = false;
PagerV2_2.Visible = true;
ViewState[“MatrixRow”] = MatrixRow;
int Pagesize = PagerV2_1.PageSize;
int CurrentPage = PagerV2_1.CurrentIndex;
int lowerBand;
int upperband;
lowerBand = (CurrentPage – 1) * Pagesize;
upperband = (CurrentPage * Pagesize) + 1;
//Get datatable and bind data list
HdRowCount.Value = dtstyle.Rows.Count.ToString();
if (HdRowCount.Value == “0”)
{
PagerV2_1.Visible = false;
PagerV2_2.Visible = false;
}
PagerV2_1.ItemCount = Convert.ToInt32(HdRowCount.Value);
PagerV2_2.ItemCount = Convert.ToInt32(HdRowCount.Value);
PagerV2_1.ForeColor = System.Drawing.Color.FromArgb(102, 204, 204);
On Rowcommand event of pager
protected void PagerV2_2_Command(object sender, CommandEventArgs e)
{
try
{
int currnetPageIndx = Convert.ToInt32(e.CommandArgument);
PagerV2_1.CurrentIndex = currnetPageIndx;
PagerV2_2.CurrentIndex = currnetPageIndx;
binddtl();
Session[“pageindex”] = currnetPageIndx;
}
catch (Exception)
{
throw;
}
}
