Click here to Skip to main content
15,907,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I having a problem with my paging after filtering because it will postback when we try to click page 2 of gridview after filtering it. Did anyone can help me or give some idea how to overcome it? Below is my code for paging :


C#
protected void gvPaging(object sender, GridViewPageEventArgs e)
       {

           GridView1.PageIndex = e.NewPageIndex;
           GridView1.DataBind();


       }
Posted

try this
C#
protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
   {
       int rowIndex = e.NewSelectedIndex;
       LabelByRowIndex(rowIndex);
   }

private void LabelByRowIndex(int rowIndex)
    {
        MessageLabel.Text = string.Format("{0}", rowIndex + 1);
        txtFirstName.Text = GridView1.Rows[rowIndex].Cells[0].Text;
        txtMiddleName.Text = GridView1.Rows[rowIndex].Cells[1].Text;
        txtLastName.Text = GridView1.Rows[rowIndex].Cells[2].Text;
        txtDateOfBirth.Text = GridView1.Rows[rowIndex].Cells[3].Text;
        rbGender.Text = GridView1.Rows[rowIndex].Cells[4].Text;
        txtEmail.Text = GridView1.Rows[rowIndex].Cells[5].Text;
        ddlOccupation.Text = GridView1.Rows[rowIndex].Cells[6].Text;
       
    }

hope it wil help u..
accept answer if ur problm is solved..thanks
 
Share this answer
 
Before
C#
GridView.DataBind()
assign datasource to gridview
 
Share this answer
 
v2
I just need to put
C#
GridViewRow rows = GridView1.Rows[Convert.ToInt32(e.CommandArgument)];

under specific action command.
 
Share this answer
 
v2

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