foreach (Control ct in this.Controls)
{
if (ct.GetType().ToString().Equals("System.Web.UI.WebControls.CheckBox"))
{
CheckBox cb = (CheckBox)ct;
if (cb.Checked)
{
Stu.Gexing += cb.Text;
}
}
}
想遍历页面上所有的checkbox 然后把选中的值添到数据库 这个代码是网上找的 就是进不了if里面
{
if (ct.GetType().ToString().Equals("System.Web.UI.WebControls.CheckBox"))
{
CheckBox cb = (CheckBox)ct;
if (cb.Checked)
{
Stu.Gexing += cb.Text;
}
}
}
想遍历页面上所有的checkbox 然后把选中的值添到数据库 这个代码是网上找的 就是进不了if里面
{
if (ct is CheckBox)
{
CheckBox cb = (CheckBox)ct;
if (cb.Checked)
{
Stu.Gexing += cb.Text;
}
}
}
if (ct is CheckBox) {
CheckBox cb = (CheckBox)ct;
if (cb.Checked) {
Stu.Gexing += cb.Text;
}
}
}
{
if (c.HasChildren)
{
foreach (Control ct in c.Controls)
{
SetStus(ct);
}
}
if (c is CheckBox)
{
CheckBox cb = (CheckBox)c;
if (c.Checked)
{
Stu.Gexing += c.Text;
}
}
}调用:
SetStus(this);