简体   繁体   English

提交点击时未选中gridview中的复选框为true

[英]checkbox in gridview not checked is true when submit click

checkbox in gridview not checked is flase when submit click But when i modify and update button click checked is TRUE 提交单击时,GridView中的未选中复选框处于未选中状态,但是当我修改并更新按钮时,单击选中为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);
}

The reason could be you are binding the Gridview on page_load function. 原因可能是您将Gridview绑定在page_load函数上。

Bind it inside !IsPostback and it should work. 将其绑定到!IsPostback ,它应该可以工作。

if (Page.IsPostBack)
{
    //bind your grid here.
 }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM