Code
前台:
<asp:Panel ID = "pnlCondition" runat="server" Width = "100%">
</asp:Panel>
后台:LiteralControl lc = null;
DropDownList ddl = null;
Label lbl = null;
TextBox txt = null; //定义为全局
//加载
DataTable dtKeyInfo = DB.ExecuteDataSet(dc).Tables[0]; //得到配置表中每个栏位的定义
lc = new LiteralControl("<table>");
pnlCondition.Controls.Add(lc);
for (int i = 0; i < dtKeyInfo.Rows.Count; i++)
{
lc = new LiteralControl("<tr>");
pnlCondition.Controls.Add(lc);
lc = new LiteralControl("<td class='Field_Label'>");
pnlCondition.Controls.Add(lc);
lbl = new Label();
lbl.ID = i.ToString();
lbl.Text = dtKeyInfo.Rows[i]["fieldname"].ToString();
pnlCondition.Controls.Add(lbl);
lc = new LiteralControl("</td>");
pnlCondition.Controls.Add(lc);
lc = new LiteralControl("<td>");
pnlCondition.Controls.Add(lc);
string column = dtKeyInfo.Rows[i]["fieldname"].ToString();
if (dtKeyInfo.Rows[i]["uitype"].ToString() == "ddl")
{
ddl = new DropDownList();
ddl.ID = column;
this.BindDDl(ddl,column);
pnlCondition.Controls.Add(ddl);
}
if (dtKeyInfo.Rows[i]["uitype"].ToString() == "txt")
{
txt = new TextBox();
txt.ID = column;
txt.MaxLength = 10;
pnlCondition.Controls.Add(txt);
}
lc = new LiteralControl("</td>");
pnlCondition.Controls.Add(lc);
lc = new LiteralControl("</tr>");
pnlCondition.Controls.Add(lc);
}
lc = new LiteralControl("</table>");
pnlCondition.Controls.Add(lc);
前台:
<asp:Panel ID = "pnlCondition" runat="server" Width = "100%">
</asp:Panel>
后台:LiteralControl lc = null;
DropDownList ddl = null;
Label lbl = null;
TextBox txt = null; //定义为全局
//加载
DataTable dtKeyInfo = DB.ExecuteDataSet(dc).Tables[0]; //得到配置表中每个栏位的定义
lc = new LiteralControl("<table>");
pnlCondition.Controls.Add(lc);
for (int i = 0; i < dtKeyInfo.Rows.Count; i++)
{
lc = new LiteralControl("<tr>");
pnlCondition.Controls.Add(lc);
lc = new LiteralControl("<td class='Field_Label'>");
pnlCondition.Controls.Add(lc);
lbl = new Label();
lbl.ID = i.ToString();
lbl.Text = dtKeyInfo.Rows[i]["fieldname"].ToString();
pnlCondition.Controls.Add(lbl);
lc = new LiteralControl("</td>");
pnlCondition.Controls.Add(lc);
lc = new LiteralControl("<td>");
pnlCondition.Controls.Add(lc);
string column = dtKeyInfo.Rows[i]["fieldname"].ToString();
if (dtKeyInfo.Rows[i]["uitype"].ToString() == "ddl")
{
ddl = new DropDownList();
ddl.ID = column;
this.BindDDl(ddl,column);
pnlCondition.Controls.Add(ddl);
}
if (dtKeyInfo.Rows[i]["uitype"].ToString() == "txt")
{
txt = new TextBox();
txt.ID = column;
txt.MaxLength = 10;
pnlCondition.Controls.Add(txt);
}
lc = new LiteralControl("</td>");
pnlCondition.Controls.Add(lc);
lc = new LiteralControl("</tr>");
pnlCondition.Controls.Add(lc);
}
lc = new LiteralControl("</table>");
pnlCondition.Controls.Add(lc);