我查了一下资料,动态生成的页面后,你可以遍历整个页面的控件,然后根据既定规则,对应将值填入数据库,再要复杂就要多写代码了. private void OperateControls(Control control) { foreach(Control c in control.Controls) { if(c is Panel) { OperateControls(c); } if(c is GroupBox) { OperateControls(c); } if(c is TextBox) { // 它是 TextBox, 要干什么随便你 } } }
调用时用: OperateControls(this); 也可以 private void FindButton(Control c) { if (c.Controls != null) { // foreach(Control x in c.Controls) { if (x is TextBox) { sss=sss+((TextBox)x).Text; } if (x is DropDownList) sss=sss+((DropDownList)x).SelectedValue; FindButton(x); } } } 调用:FindButton(this);
{
foreach(Control c in control.Controls)
{
if(c is Panel)
{
OperateControls(c);
}
if(c is GroupBox)
{
OperateControls(c);
}
if(c is TextBox)
{
// 它是 TextBox, 要干什么随便你
}
}
}
调用时用:
OperateControls(this); 也可以 private void FindButton(Control c)
{
if (c.Controls != null)
{
//
foreach(Control x in c.Controls)
{
if (x is TextBox)
{
sss=sss+((TextBox)x).Text;
}
if (x is DropDownList)
sss=sss+((DropDownList)x).SelectedValue;
FindButton(x);
}
}
}
调用:FindButton(this);