table控件换行问题.在线求解

evan84786088 2011-03-21 04:13:48

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);
}
}


执行效果如下



问题:1,如何把“班组6”移动到“段队5”的位置。

2,"段队5"单独占一行,也就是“TEXT”类型单独占一行

在线求解
...全文
198 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
evan84786088 2011-03-21
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 rock870210 的回复:]

最简单的办法就是把所有Text类型的保存起来,等到所有都放完了,再放置Text类型的!
[/Quote]

这个好像有点用处,问题就是怎么TEXT类型往table控件中间插入
hl362496158 2011-03-21
  • 打赏
  • 举报
回复
rowspan 和 cosspan 合并行列
Rock870210 2011-03-21
  • 打赏
  • 举报
回复
最简单的办法就是把所有Text类型的保存起来,等到所有都放完了,再放置Text类型的!
子夜__ 2011-03-21
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 evan84786088 的回复:]

引用 3 楼 ranen2010 的回复:

合并单元格,和你用html设计table的时候一样,具体属性你找找吧,html 是rowspan,和cosspan


我明白你的意思!但是ListBox在第一列好办,如果在第二列colsoan也没用呀
[/Quote]

可以看看你生成的HTML 然后摆正位置的HTML 形成对比后 修改你的后台代码。。
evan84786088 2011-03-21
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 masschoi 的回复:]

1个row只加1个Cell
[/Quote]

我是要一行两列,ListBox单独占一列
evan84786088 2011-03-21
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 ranen2010 的回复:]

合并单元格,和你用html设计table的时候一样,具体属性你找找吧,html 是rowspan,和cosspan
[/Quote]

我明白你的意思!但是ListBox在第一列好办,如果在第二列colsoan也没用呀
evan84786088 2011-03-21
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 yangyi_33855 的回复:]

楼主想要问的是自动换行问题么?问题看不明白啊~~求补充!
[/Quote]

对,其实就是自动换行。类型为“TEXT”自动换行,单独占一行。但是前一行只有一列的话自动补充一列
小童 2011-03-21
  • 打赏
  • 举报
回复
合并单元格,和你用html设计table的时候一样,具体属性你找找吧,html 是rowspan,和cosspan
唵嘛呢叭咪吽 2011-03-21
  • 打赏
  • 举报
回复
1个row只加1个Cell
yangyi_33855 2011-03-21
  • 打赏
  • 举报
回复
楼主想要问的是自动换行问题么?问题看不明白啊~~求补充!

62,047

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧