复选框为false但是当我修改和更新按钮时单击选中则为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);
}
答案 0 :(得分:1)
原因可能是您在Gridview
函数上绑定了page_load
。
将其绑定在!IsPostback
内,它应该有效。
if (Page.IsPostBack)
{
//bind your grid here.
}