Dynamically loading server controls (collation)

Source: Internet
Author: User
code Example 1:

Dlist = New System.Web.UI.WebControls.DropDownList ()
Dlist. Items.clear ()
Dlist.id = "D" & rs2. Fields ("ZDM"). Value

Do as not RS3. Eof
Dlist. Items.Add (RS3. Fields (0). Value)
Rs3. MoveNext ()
Loop

Td2. Controls.Add (Dlist)

code Example 2:
TextBox textbox = new TextBox ();
textbox.id = Showreader.getvalue (0). ToString ();
This. Controls.Add (textbox);

code Example 3:
Override to create repeated items.
protected override void CreateChildControls () {
Object o = viewstate["NumItems"];
if (o!= null) {
Clear any existing the child controls.
Controls.clear ();

int numitems = (int) o;
for (int i=0 i < NumItems; i++) {
Create an item.
RepeaterItem item = new RepeaterItem (i, NULL);
Initialize the item from the template.
Itemtemplate.instantiatein (item);
ADD the item to the ControlCollection.
Controls.Add (item);
}
}
}

Note
The new control is added to the end of the ordinal index array. A control can be any ASP.net server control, a custom server control that you create, or an instance of a text control.

To add a control to a specific index location in the collection, use the AddAt method.






Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.