我做了一个gridview,其中一列为checkbox点击某按钮后,将gridview中checkbox被选中的行选出来做处理,代码如下问题是,调试代码过程中,选中的checkbox也说没有选中
protected void Button10_Click(object sender, EventArgs e)
{
for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
{
CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");
if (cbox.Checked == true)
{
...//处理代码
}
else
{
...//处理代码
}
}
}
protected void Button10_Click(object sender, EventArgs e)
{
for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
{
CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");
if (cbox.Checked == true)
{
...//处理代码
}
else
{
...//处理代码
}
}
}
{ RadioButton rdA = (RadioButton)dr.FindControl("rdA");
RadioButton rdB = dr.FindControl("rdB") as RadioButton;
RadioButton rdC = dr.FindControl("rdC") as RadioButton;
RadioButton rdD = dr.FindControl("rdD") as RadioButton;
string Answer = "";
if (rdA.Checked)
{
Answer = "A"; }
else if (rdB.Checked)
{
Answer = "B";
}
else if (rdC.Checked)
{
Answer = "C";
}
else if (rdD.Checked)
{
Answer = "D";
}
else
{
Answer = "";
}
就算选中 调试的时候checked也是false
不知所措中~~
前台:<asp:TreeView ID="TreeView1" ShowCheckBoxes="All" runat="server"
ShowLines="True" ontreenodecheckchanged="Node_CheckChanged" >
后台:protected TreeNodeCollection tnodelist = new TreeNodeCollection();
protected void Node_CheckChanged(object sender, TreeNodeEventArgs e)
{
tnodelist.Add(e.Node);
}