62,047
社区成员
发帖
与我相关
我的任务
分享
protected void Page_Load(object sender, EventArgs e)
{
int numrows;
int i = 0;
int j = 0;
int n = 0;
TableRow tr;
TableCell tc;
string fsql = "select field_name,description,default_value,field_type from sys_field where table_id='1' and field_type is not null order by seq_no";
DataTable dsql = OperateData.getRows(fsql);
numrows = dsql.Rows.Count;//总行数
for (i = 0; i < numrows; i++)
{
tr = new TableRow();
for (j = 0; j < 2; j++)
{
//c = new TableCell();
//c.Controls.Add(new LiteralControl("row" + j + ",cell" + i));
//r.Cells.Add(c);
if (n < numrows)
{
string Type = dsql.Rows[n]["field_type"].ToString();
string field_name = dsql.Rows[n]["field_name"].ToString();
string description = dsql.Rows[n]["description"].ToString();
if (Type == "TXT")
{
TableCell txt = new TableCell();
Label tx = new Label();
tx.Text = description + n;
txt.Controls.Add(tx);
tr.Cells.Add(txt);
tc = new TableCell();
TextBox tb = new TextBox();
tb.ID = field_name + "$C3T4L5$" + n;
tc.Controls.Add(tb);
tr.Cells.Add(tc);
}
else if (Type == "DAT")
{
TableCell txt = new TableCell();
Label tx = new Label();
tx.Text = description + n;
txt.Controls.Add(tx);
tr.Cells.Add(txt);
tc = new TableCell();
TextBox tb = new TextBox();
tb.ID = field_name + "$C3T4L5$" + n;
tc.Controls.Add(tb);
tr.Cells.Add(tc);
}
else if (Type == "OPT")
{
TableCell txt = new TableCell();
Label tx = new Label();
tx.Text = description + n;
txt.Controls.Add(tx);
tr.Cells.Add(txt);
tc = new TableCell();
DropDownList tb = new DropDownList();
tb.ID = field_name + "$C3T4L5$" + n;
tc.Controls.Add(tb);
tr.Cells.Add(tc);
}
else if (Type == "RAD")
{
TableCell txt = new TableCell();
Label tx = new Label();
tx.Text = description + n;
txt.Controls.Add(tx);
tr.Cells.Add(txt);
tc = new TableCell();
RadioButton tb = new RadioButton();
tb.ID = field_name + "$C3T4L5$" + n;
tc.Controls.Add(tb);
tr.Cells.Add(tc);
}
else if (Type == "BOX")
{
TableCell txt = new TableCell();
Label tx = new Label();
tx.Text = description + n;
txt.Controls.Add(tx);
tr.Cells.Add(txt);
tc = new TableCell();
CheckBox tb = new CheckBox();
tb.ID = field_name + "$C3T4L5$" + n;
tc.Controls.Add(tb);
tr.Cells.Add(tc);
}
else if (Type == "TEXT")
{
TableCell txt = new TableCell();
Label tx = new Label();
tx.Text = description + n;
txt.Controls.Add(tx);
tr.Cells.Add(txt);
tc = new TableCell();
ListBox tb = new ListBox();
tb.ID = field_name + "$C3T4L5$" + n;
tc.Controls.Add(tb);
tr.Cells.Add(tc);
}
else if (Type == "ATT")
{
TableCell txt = new TableCell();
Label tx = new Label();
tx.Text = description + n;
txt.Controls.Add(tx);
tr.Cells.Add(txt);
tc = new TableCell();
FileUpload tb = new FileUpload();
tb.ID = field_name + "$C3T4L5$" + n;
tc.Controls.Add(tb);
tr.Cells.Add(tc);
}
Response.Write("<li>行=" + j + ",列=" + i + ",序号=" + n + ",类型=" + Type +",字段"+ field_name);
n += 1;
}
}
Table1.Rows.Add(tr);
}
}