. Net background to get the value of CheckBoxList,. netcheckboxlist

Source: Internet
Author: User

. Net background to get the value of CheckBoxList,. netcheckboxlist

. Net background to obtain the CheckBoxList value.

1. Front-end multi-choice controls

2. Obtain multiple values in the background

String str = string. Empty;

Foreach (ListItem li in cblStr. Items)

{

If (li. Selected = true)

{

Str + = li. Value + ",";

}

}

Str. TrimEnd (','); is the multiple values you need

Third: assign a value to the CheckBoxList

Foreach (string str in split)

{

For (int I = 0; I <CheckBoxList1.Items. Count; I ++)

{

If (CheckBoxList1.Items [I]. Text = str)

{

CheckBoxList1.Items [I]. Selected = true;

}

}

}

Type 4: determine whether or not to select

Var flag1 = 0;

Var checkobj = document. getElementById ("CheckBoxList1 ");

Var checks = checkobj. getElementsByTagName ("input ");

For (var n = 0; n {

If (checks [n]. type = "checkbox" & checks [n]. checked = true)

{

Flag1 = 1;

}

}

If (flag1 = 0)

{

Alert ("Select Topic settings! ");

Return false;

}

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.