Click here to Skip to main content
15,794,275 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I was able to get alphabetical paging in a Gridview. Problem - when I click the page 2(or 3 or 4 etc) for records whose records are more than the page size of 10, the alphabetic sorting is changed . I guess this is cause of the code in the page index changing event.Maybe I would need to change the "Constr" for the next 10 records of the selected Alphabet. Please help

protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
     GridView1.PageIndex = e.NewPageIndex;
     constr = Select FirstName,MiddleName,LastName,Suffix from Offnames;

where the binddata is

public void binddata(string s)
     SqlDataAdapter da = new SqlDataAdapter(constr, con);
     DataSet ds = new DataSet();
     GridView1.DataSource = ds;
Updated 5-Apr-12 14:12pm
Nelek 5-Apr-12 19:12pm    
Tags added
demouser743 7-Apr-12 5:39am    
What error you are getting
demouser743 7-Apr-12 6:01am    
Check this
Sonycj 9-Apr-12 10:33am    
Dorababu743 - The link shows Alphabetic GridView paging(my code works to that point),but does not restrict the records on the page(say 5 records).If there are a 100 records under "A", its lists them all.I would like to set a page limit of 10 records each.

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