Private void createconfigtable (INT totalnum, int [] sequenceint, string [] namestr, string [] ipstr)
{
// Dynamically generate an input box based on the total number of measurement points
For (INT I = 1; I <= totalnum; I ++)
{
// Create a table
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 );
// Create a row
Htmltablerow Trow = new htmltablerow ();
Showtable. Rows. Add (Trow );
// Create the first column (sequence number)
Htmltablecell Tcell = new htmltablecell ();
Label sequencelabel = new label ();
Sequencelabel. ID = "sequencelabel" + I. tostring ();
Sequencelabel. Text = "No :";
Sequencelabel. Enabled = true;
Tcell. Controls. Add (sequencelabel );
Trow. cells. Add (Tcell );
// Create the second column
Tcell = new htmltablecell ();
Sequencedatatb = new Textbox ();
Sequencedatatb. ID = "sequencedatatb" + I. tostring ();
Sequencedatatb. Text = I. tostring ();
Sequencedatatb. width = 30;
Sequencedatatb. Text = sequenceint [I]. tostring ();
Sequencedatatb. readonly = false;
// Create the third column (name)
Tcell = new htmltablecell ();
Label namelabel = new label ();
Namelabel. ID = "namelabel" + I. tostring ();
Namelabel. Text = "name :";
Namelabel. Enabled = true;
Tcell. Controls. Add (namelabel );
Trow. cells. Add (Tcell );
// Create the fourth column
Tcell = new htmltablecell ();
Nametb = new Textbox ();
Nametb. ID = "nametb" + I. tostring ();
Nametb. width = 120;
Nametb. Text = namestr [I];
Nametb. maxlength = 50;
Tcell. Controls. Add (nametb );
Trow. cells. Add (Tcell );
// Create the Fifth Column (IP)
Tcell = new htmltablecell ();
Label iplabel = new label ();
Iplabel. ID = "iplabel" + I. tostring ();
Iplabel. Text = "IP :";
Iplabel. Enabled = true;
Tcell. Controls. Add (iplabel );
Trow. cells. Add (Tcell );
// Create column 6
Tcell = new htmltablecell ();
Iptb = new Textbox ();
Iptb. ID = "iptb" + I. tostring ();
Ipterabytes. width = 120;
Iptb. Text = ipstr [I];
Iptb. maxlength = 15;
Tcell. Controls. Add (iptb );
Trow. cells. Add (Tcell );
}
}
Tcell. Controls. Add (sequencedatatb );
Trow. cells. Add (Tcell );
... ...
// Create the Fifth Column (IP)
Tcell = new htmltablecell ();
Label iplabel = new label ();
Iplabel. ID = "iplabel" + I. tostring ();
Iplabel. Text = "IP :";
Iplabel. Enabled = true;
Tcell. Controls. Add (iplabel );
Trow. cells. Add (Tcell );
// Create column 6
Tcell = new htmltablecell ();
Iptb = new Textbox ();
Iptb. ID = "iptb" + I. tostring ();
Ipterabytes. width = 120;
Iptb. Text = ipstr [I];
Iptb. maxlength = 15;
Tcell. Controls. Add (iptb );
Trow. cells. Add (Tcell );
}
}
Myplaceholder in the program is the system. Web. UI. webcontrols. placeholder component. The HTML Syntax of this component is as follows:
This component is used to locate dynamically created tables. The position of this component on the page is the position of the dynamically created table.
Another note in the program is to set the ID of the dynamically created component. Pay attention to the following two points for setting the component ID:
1. the ID number cannot be repeated.
2. It should be easy to use in programs. Because you want to use a dynamically created component in the program, you need to find it by the component ID. (For details about this, refer to "using dynamically created web components)
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service