Pagination Custamization:
1).aspx/.ascx Design View
2).aspx.cs/.ascx.cs
private int intCurrentselectPage;
#region CurrentselectPage
public int CurrentSelectPage
{
get
{
return intCurrentselectPage;
}
set
{
intCurrentselectPage = value;
}
}
#endregion
protected void grdNewsList_DataBound(object sender, EventArgs e)
{
if (grdNewsList.Rows.Count > 0)
{
GridViewRow gNavFooter = grdNewsList.BottomPagerRow;
LinkButton lbP = gNavFooter.FindControl("lbPrev") as LinkButton;
LinkButton lbN = gNavFooter.FindControl("lbNext") as LinkButton;
try
{
if (grdNewsList.PageIndex == 0)
{
lbP.Enabled = false;
}
int iStartIndex = 0;
int iCurrentPage = CurrentSelectPage + 1;
int iCalc = (iCurrentPage / 5) + ((iCurrentPage % 5) >= 1 ? 1 : (iCurrentPage % 5));
if (iCalc > 1)
{
iStartIndex = (((iCalc * 5) - 5) + 1);
}
else
{
iStartIndex = 1;
}
for (int i = 1; i <= 5; i++)
{
LinkButton lb = gNavFooter.FindControl("lb" + i.ToString()) as LinkButton;
lb.Text = iStartIndex.ToString();
lb.CommandArgument = iStartIndex.ToString();
if (iStartIndex > grdNewsList.PageCount)
{
lb.Visible = false;
}
if (iStartIndex == grdNewsList.PageIndex + 1)
{
lb.Enabled = false;
}
iStartIndex++;
}
if (grdNewsList.PageIndex == grdNewsList.PageCount - 1)
{
lbN.Enabled = false;
}
}
catch (Exception ex)
{
throw (ex);
}
}
}
protected void grdNewsList_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
CurrentSelectPage = e.NewPageIndex;
grdNewsList.PageIndex = e.NewPageIndex;
DisplayFromListPublishedNews(); // Bind the Method again.
}
ஏஞ்சல்
என்னை பற்றி
Google reader
Categories
- .Net (9)
- .Net Crystal Report (1)
- .Net GridView (3)
- Articles (5)
- Log File .Net (1)
- Sharepoint (2)
- Sitefinity 3.7 (3)
- SQL (5)
- Technical Question and Ans (3)
- Validation (1)
- XML (2)
Friday, May 22, 2009
Pagination Custamization
Posted by Meera at 12:16 AM
Labels: .Net GridView
When hearts listen
angel sing.If you seek an angel with an open heart...
You shall always find loved one