0

checkbox in gridview not checked is flase when submit click But when i modify and update button click checked is TRUE

public void addchapselect()
{
    TextBox1.Text = "";

    for (int i = 0; i < gvChapter.Rows.Count; i++)
    {

        CheckBox chkbox = (CheckBox)gvChapter.Rows[i].Cells[0].FindControl("chkSelect");
        if (chkbox != null)
        {
            if (chkbox.Checked)
            {

                TextBox1.Text += Convert.ToString(gvChapter.Rows[i].Cells[0].Text) + ",";

                // ItemValueId = ItemValueId + ",";
                string Name = Convert.ToString(gvChapter.Rows[i].Cells[1].Text);



            }
        }
        chkbox.Checked = false;
    }
    if (TextBox1.Text != "")
        TextBox1.Text = TextBox1.Text.Substring(0, TextBox1.Text.Length - 1);
}
6
  • on which event this code runs\ Commented Jan 30, 2014 at 7:08
  • on button click event Commented Jan 30, 2014 at 7:11
  • @Atul would you please paste your button click event code ? Commented Jan 30, 2014 at 7:12
  • this is function call on submit and modify buuton Commented Jan 30, 2014 at 7:16
  • paste your HTML Code and Page Load Code. Commented Jan 30, 2014 at 7:24

1 Answer 1

1

The reason could be you are binding the Gridview on page_load function.

Bind it inside !IsPostback and it should work.

if (Page.IsPostBack)
{
    //bind your grid here.
 }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.