打印本文 打印本文 关闭窗口 关闭窗口
ASP.NET中根据XML动态创建并使用WEB组件(二)
作者:武汉SEO闵涛  文章来源:敏韬网  点击数2551  更新时间:2009/4/23 10:46:29  文章录入:mintao  责任编辑:mintao

ASP.NET中根据XML动态创建使用WEB组件

(二)

作者:厉铁帅

三、动态创建WEB组件。

先来看程序实例:

private void createconfigtable(int totalnum,int[] sequenceint,string[] namestr,string[] ipstr)

         {

              //根据得到测量点的总数,动态生成输入框

              for(int i=1;i<=totalnum;i++)

              {

                   //创建表格

                   HtmlTable showtable = new HtmlTable();

                   showtable.Border=0;

                   showtable.ID="showtable"+i.ToString();

                   showtable.BorderColor="#000000";

                   showtable.CellPadding=4;

                   showtable.CellSpacing=4;

                   showtable.Align="center";

                   myPlaceHolder.Controls.Add(showtable);

                   //创建一行

                   HtmlTableRow tRow = new HtmlTableRow();

                   showtable.Rows.Add(tRow);

                  

                   //创建第一列(序号)

                   HtmlTableCell tCell = new HtmlTableCell();

                   Label sequenceLabel = new Label();

                   sequenceLabel.ID="sequenceLabel"+i.ToString();

                   sequenceLabel.Text="序号:";

                   sequenceLabel.Enabled=true;

                   tCell.Controls.Add(sequenceLabel);

                   tRow.Cells.Add(tCell);

                  

                   //创建第二列

                   tCell = new HtmlTableCell();

                   sequencedataTB = new TextBox();

                   sequencedataTB.ID="sequencedataTB"+i.ToString();

                   sequencedataTB.Text=i.ToString();

                   sequencedataTB.Width=30;

                   sequencedataTB.Text=sequenceint[i].ToString();

                   seq

[1] [2] [3] [4]  下一页

打印本文 打印本文 关闭窗口 关闭窗口