Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
Coding for PageIndexChanging

C#
GridBank.PageIndex = e.NewPageIndex;
GridBank.DataSource = (DataTable)ViewState["Bank"];
GridBank.DataBind();


when i click the second page or third page, it was showing the page, but when i click the SelectIndex of the second or third page, it is selecting the first page of the index, so anyone have any idea about the PageIndex
So please give some solution for this. thanks
Posted
Updated 9-May-11 1:10am
v2

This is completely a guess.

I guess you have written code for loading the GridView on the Page_Load too. If yes, make sure you check for IsPostback property and load the GridView.

Like,

C#
private void Page_Load (object sender, EventArgs e)
{
    if (!IsPostback)
    {
        //load your GridView here
    }
}


Mark it as answer if it is helpful.
 
Share this answer
 
Comments
newsbala 9-May-11 7:54am    
whatever things needed i have done, but still not getting, if u have any coding for this, plz submit, thanks
Venkatesh Mookkan 9-May-11 8:28am    
Upload your sample project somewhere and give the link to download. I will check and correct it foe you.
Following MSDN articles should give you complete overview of how datagrid's pagination work and the related code:
MSDN DataGrid.PageIndexChanged Event[^]
MSDN: Creating a Pageable, Sortable DataGrid[^]
 
Share this answer
 
When any event called on web page the PageLoad get calls prior that.
It may happens that you have not put IsPostBack in your PageLoad
 
Share this answer
 
Comments
newsbala 9-May-11 7:53am    
still not working
put viewstate["pageno"]=1 in page load

and in binding take datatable into session["dt"]=dt;

in pageindexchnage event


give session["dt"]=dt as datasource but update
int pageno=convert.toint16(viewstate["pageno"])+your page size;

viewstate["pageno"]=pageno;

i hope it helps you
 
Share this answer
 
In your SelectedIndexChanging event , you write the following code

MIDL
GridBank.PageIndex = e.NewSelectedIndex;
GridBank.DataSource = (DataTable)ViewState["Bank"];
GridBank.DataBind();


Best Regard,
Theingi Win
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900