Skip to content

Paging in GridView in asp.net 2.0

Mallik Raghu

Asked Mar 10, 2008, 6:13 PM EDT1 answer
Share
LinkedInX

i am having a gridview with autogenerate cols=false and with paging =true.1 2 3 page nos display.but  when i click on the 2nd page the grid is not visible i mean its vanishing..I got an sqldatasource.Grid is not displayed in page_load.

1.[u]page_load[/u]
if(not postback)
{
//GridView1.visible=false;no gridview binding
}

2.i got a button when clckd the gridview is displayed.in this button_click:

i am giving [b]datasourceid="sqldatasource1" in html page [/b]and i am programatically setting the sqldsource connection string  and command string properties in the [b]codebehind page[/b].

There are some data entry fields and then i [b]insert[/b] a record into the corresponding table of sqldatasource.here i am [b]displaying[/b] the gridview afterbinding ..

Gridview1.DataBind(); as already in html page i mentioned as  gridview's datasourceid="sqldatasource1".then grid is displayed but when i click on the 2nd page number link in the footer of gridview then the gridview is Vanished.. 


Thanks in advance...

 

AMR

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • paiha paiga
    0

    call the event  PageIndexChanging like

    C#
    protected void grdview_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
    GridView.PageIndex = e.NewPageIndex;
    //call here the function from which you have bind the gridview....
    }
    as well as before above process you would have to set the pagesize = something; , AllowPaging = true;
    0