Click here to Skip to main content
11,568,180 members (37,500 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
I am using vs 2010 to develop a web app
I have create a grid view as this:
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"
                               DataSourceID="SqlDataSource3" DataKeyNames="Id" AllowPaging="True" OnPageIndexChanging="GridView2_PageIndexChanging"
                               >


in page.aspx.cs i have wrote:
  protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e)
             {
                 
 
                 GridView2.PageIndex = e.NewPageIndex;
                 GridView2.DataSource = dt;
                 GridView2.DataBind();
             }

BUT THE PROBLEM IS THAT EXCEPT THE FIRST PAGE.. ALL THE OTHER PAGES 2,3,4... ARE BLANK :/
WHERE IS MY PROBLEM??
Posted 2-Jan-13 22:33pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

make your page size 4
then see.
  Permalink  
Comments
Annnaa at 3-Jan-13 4:52am
   
done but results the same probleem :/
prashant patil 4987 at 3-Jan-13 4:53am
   
what error comes paste error here.:
Annnaa at 3-Jan-13 6:53am
   
it doesnt result any error
the problem is that only the first page hase datas... all the other pages 2,3,4 .. are blank
prashant patil 4987 at 3-Jan-13 6:57am
   
how can this... if other pages doesnot have any data then how could see these pages number on grid page row
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Dear Friend

Here when you click your next page., server is post pack..
so dt (datatable or dataset) should be empty.,
that is the problem., so you try to keep dt value as viewstate like


when you getting data from database then you assign like.,
viewstate("dt_data")=dt;
GridView2.DataSource = dt;
GridView2.DataBind();

then now you add page index changing code like this..

protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e)
            {
 

                GridView2.PageIndex = e.NewPageIndex;
                GridView2.DataSource = viewstate("dt_data");
                GridView2.DataBind();
            }

that's all..

now you check page index is working fine.,


I hope this information is helpful to you.,

Thanks and regards

Angappan.s
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

first you do
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"
                               DataSourceID="SqlDataSource3" DataKeyNames="Id" AllowPaging="True" OnPageIndexChanging="GridView2_PageIndexChanging"
                               
  pageSize="10">

if you give
    DataSourceID="SqlDataSource3"
then no need to DataSource =dt

just only write


protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e)
             {
 

                 GridView2.PageIndex = e.NewPageIndex;
                                 GridView2.DataBind();
             }


Please build it and used it if Probelm Persist than give your comment..
  Permalink  

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

  Print Answers RSS


Advertise | Privacy | Mobile
Web04 | 2.8.150624.2 | Last Updated 4 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100