Use. Perform a drop-down menu and control the currently displayed date. Use the add set of controls and listitem.

Source: Internet
Author: User

Private void Page_Load (object sender, System. EventArgs e)
{
If (! Page. IsPostBack) // Page loading mainly assigns values to the following list.
{
For (int I = 1; I <13; I ++)
{
This. DropDownList1.Items. Add (new ListItem (I. ToString ()));
}
For (int I = 1900; I <2050; I ++)
{
This. DropDownList2.Items. Add (new ListItem (I. ToString ()));
}
}
// Place user code here to initialize the page
}

Form Generation Code
Private void button#click (object sender, System. EventArgs e)
{
// Add controls in the panel using the add set of controls
Int txtw.convert.toint32(this.txt num. Text );
Int btn = Convert. ToInt32 (this. btnnum. Text );
For (int I = 0; I <txt; I ++)
{
This. Panel1.Controls. Add (new TextBox ());
}
For (int I = 0; I <btn; I ++)
{
This. panel1.Controls. add (new Button (); // I have not found a method for adding words to the Button. I have tried several methods. Please let me know if you are interested. Thank you!
}
}

Private void dropdownlistpolicselectedindexchanged (object sender, System. EventArgs e)
{
Int y = Convert. ToInt32 (this. DropDownList2.SelectedItem. Text); // assign a value to the year
Int m = Convert. ToInt32 (this. DropDownList1.SelectedItem. Text); // assign a value to the month
This. Calendar1.VisibleDate = Convert. ToDateTime (m + "/01/" + y); // tell the control to display this day
}

Private void DropDownList2_SelectedIndexChanged (object sender, System. EventArgs e)
{
Int y = Convert. ToInt32 (this. DropDownList2.SelectedItem. Text );
Int m = Convert. ToInt32 (this. DropDownList1.SelectedItem. Text); // same as above
This. Calendar1.VisibleDate = Convert. ToDateTime (m + "/01/" + y );
}

----------------------------------------------------------------
There is a panel, two dropdownlists, two textbox, and one button on the page.

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.