20151220 What to learn: web radio box, check box

Source: Internet
Author: User

 Radio Box: RadioButtonRadioButton has a property groupname, when selected, the group name of each option must be set to the same View button is checked:BOOLSex =radiobutton1.checked; Label1.Text=sex. ToString (); radio button list: RadioButtonList properties: repeatdirection: Horizontally or vertically bound data: Textdatacontext context=NewTextdatacontext (); Radiobuttonlist1.datasource=context.        Nation; Radiobuttonlist1.datatextfield="Name"; Radiobuttonlist1.datavaluefield="Code";    Radiobuttonlist1.databind (); Value of the selected item: Label1.Text=RadioButtonList1.SelectedValue.ToString (); Set which item is selected: Radiobuttonlist1.selectedindex=2; check box: checkbox to see if the button is selected: CheckBox1.    Checked; The rest is the same as the box check box list: CheckBoxList property RepeatDirection: Horizontal or portrait vertical bound data: Checkboxlist1.datasource =context.        Nation; Checkboxlist1.datatextfield="Name"; Checkboxlist1.datavaluefield="Code";    Checkboxlist1.databind (); Value of the selected item: Label1.Text="";//Clear        foreach(ListItem Iteminchcheckboxlist1.items) {if(item. Selected) {Label1.Text+=item.            Text; }} Set which item is selected: Single-checked: Checkboxlist1.selectedindex=2; Multiple-item selection:foreach(ListItem Iteminchcheckboxlist1.items) {if(item. Text = ="Han"|| Item. Text = ="Manchu") {Item. Selected=true; }} Example: If the code is not executed, it is likely that AutoPostBack is not set to Ture

20151220 What to learn: web radio box, check box

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.