Asp.net radiobuttonlist and checkbox

Source: Internet
Author: User

 

Asp.net radiobuttonlist

Radiobuttonlist1.items [radiobuttonlist1.selectedindex]. Value
Request. Form ["radiobuttonlistname"]
If (radiobuttonlist1.selectedindex>-1)
{
Label1.text = "you chose:" + radiobuttonlist1.selecteditem. text;
}
Radiobuttonlist1.selecteditem. Text
Radiobuttonlist1.selecteditem. Value

Non-null judgment is not required
Radiobuttonlist1.selectedvalue

 

 

Asp.net checkboxlist value and check box, check box background control foreground checkbox Selection

Three backend methods:
First: Get the checkbox Value

 

C # code
String save_cbljl = ""; for (INT I = 0; I <this. cbljl. items. count; I ++) {If (this. cbljl. items [I]. selected = true) {save_cbljl + = This. cbljl. items [I]. value + "," ;}} response. write (save_cbljl); string save_cbljl = "";
For (INT I = 0; I <this. cbljl. Items. Count; I ++)
{
If (this. cbljl. items [I]. Selected = true)
{
Save_cbljl + = This. cbljl. items [I]. Value + ",";
}
}
Response. Write (save_cbljl );

Type 2: Get the checkbox Value

 

C # code
String str_save_cbljl = ""; foreach (listitem Li in cbljl. items) {If (Li. selected = true) {str_save_cbljl + = Li. value + "," ;}} response. write (str_save_cbljl); string str_save_cbljl = "";
Foreach (listitem Li in cbljl. Items)
{
If (Li. Selected = true)
{
Str_save_cbljl + = Li. Value + ",";
}
}
Response. Write (str_save_cbljl );

Third: assign a value to the front-end checkbox from the background

 

C # code
String Strapp = "Record 1, record 2, record 3 ,";

String [] strtemp = Strapp. Split (',');

Foreach (string STR in strtemp)

{For (INT I = 0; I <cbljl. Items. Count; I ++)

{If (this. cbljl. items [I]. value = Str)

{

This. cbljl. items [I]. Selected = true;

}

}

}

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.