954,574 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Girdview Pagination Disappears

i had used gridview to display records from database, i am able to display records but in pagination when i click 2,3,4,5......10 page the gridview disappears.

find the code below for gridview:

<asp:GridView ID="GridView1"   runat="server"  AllowPaging="True" PageSize="10"   AutoGenerateColumns="False" OnPageIndexChanging="GridView1_PageIndexChanging" onselectedindexchanged="GridView1_SelectedIndexChanged"
        GridLines="Horizontal">

code behind:

    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.BottomPagerRow.Visible = true;
       
        GridView1.PageIndex = e.NewPageIndex;
      
        GridView1.DataBind();
        
        
    }
arunmagnilagan
Newbie Poster
3 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
 

where are you setting the gridview's datasource?

Cherryhomesj
Junior Poster in Training
58 posts since Sep 2011
Reputation Points: 30
Solved Threads: 17
 

in button click i wrote dataource. i need to select date from date picker and using button click then display it in gridview.

arunmagnilagan
Newbie Poster
3 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
 

finally it worked for me:) i got it..

sorry for not posting full code..

find the below code

protected void bindgrid()
    {

if (BasicDatePicker1.SelectedDate <= DateTime.Now)
        {

            Session["sesdb"] = null;
           

            DateTime from = this.BasicDatePicker1.SelectedDate;
         

            string strSql = "query";

            DataTable dt = new DataTable();


            DataSet ds = ClassDbOperator.RetrieveBySQLStr(strSql);


            dt = ds.Tables[ClassDbOperator.TEMPTABLE];

            if (dt.Rows.Count > 0)
            {
                BtnDownload.Visible = true;
                bool bb = true;

                GridView1.DataSource = dt;
                GridView1.DataBind();
                Session["sesdb"] = dt;
                return;
            }

            Response.Redirect("Download.aspx");

        }

        else
        {     

        }

}


    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {

        GridView1.BottomPagerRow.Visible = true;
       
        GridView1.PageIndex = e.NewPageIndex;
        
        bindgrid();
        
     
        
        
    }

    protected void Button1_Click(object sender, EventArgs e)
    {

        bindgrid();
           
           

    }
arunmagnilagan
Newbie Poster
3 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You