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;
}
}
}