Thursday, May 29, 2008

Gridview- Pagging

--------------Step-1----------
Add Folowing code in .aspx page in asp:gridview paging templete
------------------------------


EnableViewState="false" Text="Previous" CommandName="page" CommandArgument="prev">

 | 
EnableViewState="false" Text="Next" CommandName="page" CommandArgument="next">

  
Text=' SSLib.GetPosition(gvOrderList)'>



-----------------------------------------------
---------------------step-2-------------------
in back-side-aspx.vb page add following
----------------------------------------------
Protected Sub Page_PreRenderComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRenderComplete
Dim Paging As New GridViewPaging
Paging.GridViewPaging(gvClientList)
End Sub
-------------------------------------------------
---------------------step-3------------------
-------------------------------------------
add following 2-class in project------------
-------------------------------------------
Class1=
-------
Public Class GridViewPaging
Function GridViewPaging(ByVal GridViewId As GridView) As Boolean
Dim pagetoprow As GridViewRow = GridViewId.TopPagerRow
Dim pagerbotomrow As GridViewRow = GridViewId.BottomPagerRow
If Not (IsNothing(pagerbotomrow)) Then
If (GridViewId.PageIndex) = 0 Then
CType(GridViewId.BottomPagerRow.FindControl("lbPrevious"), LinkButton).Enabled = False
CType(GridViewId.BottomPagerRow.FindControl("lbPrevious"), LinkButton).CssClass = "DisableLink"
End If
If (GridViewId.PageIndex + 1) = GridViewId.PageCount Then
CType(GridViewId.BottomPagerRow.FindControl("lbNext"), LinkButton).Enabled = False
CType(GridViewId.BottomPagerRow.FindControl("lbNext"), LinkButton).CssClass = "DisableLink"
End If
End If
If Not (IsNothing(pagetoprow)) Then
If (GridViewId.PageIndex) = 0 Then
CType(GridViewId.TopPagerRow.FindControl("lbPrevious"), LinkButton).Enabled = False
CType(GridViewId.TopPagerRow.FindControl("lbPrevious"), LinkButton).CssClass = "DisableLink"
End If
If (GridViewId.PageIndex + 1) = GridViewId.PageCount Then
CType(GridViewId.TopPagerRow.FindControl("lbNext"), LinkButton).Enabled = False
CType(GridViewId.TopPagerRow.FindControl("lbNext"), LinkButton).CssClass = "DisableLink"
End If
End If
End Function
---------------------------------------
------class2-----------
--------------------------------------
Public Shared Function GetPosition(ByVal gv As GridView) As String
Return "( " & (gv.PageIndex + 1).ToString & " of " & gv.PageCount & " )"
End Function

Public Shared Function GetPosition(ByVal fv As FormView) As String
Return "( " & (fv.PageIndex + 1).ToString & " of " & fv.PageCount & " )"
End Function

Public Shared Function GetPageIndex(ByVal idx As Integer) As Integer
Return idx + (CInt(HttpContext.Current.Request("Pg")) * 12)
End Function

Javascript-Auto call function

onLoad=window.setTimeout("StartText(25)",100);
var y
var timerID = 0;
function StartText(x)
{
document.getElementById ('AdOrCon').style .fontSize =x+"px";
if (x==40)
{y=1;}
else{
y=x+1;}
clearTimeout(timerID);
timerID=0;
timerID=setTimeout("StartText(y)",100);
}
function showTab(x)
{
document.getElementById('Div1').style.display="none";
document.getElementById('Div2').style.display="none";
document.getElementById('Div3').style.display="none";
document.getElementById('Div4').style.display="none";
document.getElementById('Div5').style.display="none";
document.getElementById('Div'+x).style.display="";
if (x==5)
{ y=1 ;}
else
{ y=x+1; }
clearTimeout(timerID);
timerID=0;
timerID = setTimeout("showTab(y)", 10000);

}

Javascript-window open

window.open(('ZoomImage.aspx?Categoryid=' + catid + '&pageIndex=' + curpg + '&RowPerPage=100&RowCnt=0&PgCnt=0&PgInfo=0'),'zoomimage','status=no,width=550,height=500, resizable= no, scrollbars=Yes, toolbar=no,location=no,menubar=no,left=200,top=20','');