Abraham Olatubosun

Abraham Olatubosun

  • NA
  • 471
  • 113.4k

How to retain Checkbox when GridView Next button is clicked

May 27 2016 8:22 AM
Hello all,
 
we have gridview with allow paging set to true and well porpulate with checkbox in gridview template. when the checkbox checked and the next button is clicked we notice that the previous checked checkbox turns unchecked, below is a picture of it.
 
 normally we write the code as follows :
 
   
    protected void LoaDGrid()
    {
    try
    {
    string mFile1 = drpProgramArea.SelectedItem.Text.Trim();
    string mFile = string.Empty;
    DataTable dt = new DataTable();
    GetThematic(mFile1, out mFile);
    string SQL = " SELECT * FROM tbl_defn where grouptype ='" + mFile.Trim() + "'";
    SqlConnection cn = new SqlConnection(ConnectAll.ConnectMe());
    cn.Open();
    SqlCommand cmd = new SqlCommand(SQL, cn);
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    da.Fill(dt);
   GridView1.DataSource = dt; 
   GridView1.DataBind();
    }
    catch (Exception ex)
    {
    webMessage.Show("ERROR :" + ex.Message);
    return;
    }
    }
 
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
    GridView1.PageIndex = e.NewPageIndex;
    GridView1.DataBind();
    LoaDGrid();
    }
 
 
Please kindly assist us in resolving the pending challenge.
 
thank you 
 
 
 

Answers (1)