Click here to Skip to main content
15,883,883 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi,
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

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

where the binddata is

C#
public void binddata(string s)
  {
     SqlDataAdapter da = new SqlDataAdapter(constr, con);
     DataSet ds = new DataSet();
     da.Fill(ds);
     GridView1.DataSource = ds;
     GridView1.DataBind();
  }
Posted
Updated 5-Apr-12 13:12pm
v2
Comments
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 http://www.aspdotnetcodes.com/Example_Alphabetic_GridView_Paging.aspx
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