Copy Code code as follows: 
 
 
  
 
 
public partial class _default:system.web.ui.page 
 
{ 
 
Protected string title= "everyone good"; Front Code <title><% #title%></title> 
 
protected void Page_Load (object sender, EventArgs e) 
 
{ 
 
DataSet ds = new DataSet (); 
 
String sql = configurationmanager.connectionstrings["strSQL"]. ConnectionString; 
 
Using (SqlConnection sqlcnn=new SqlConnection (SQL)) 
 
{ 
 
using (SqlCommand Sqlcmm=sqlcnn.createcommand ()) 
 
{ 
 
Sqlcmm.commandtext = "SELECT * from List"; 
 
SqlDataAdapter adapter = new SqlDataAdapter (SQLCMM); 
 
Adapter. Fill (DS); 
 
} 
 
This. Radiobuttonlist1.datasource = ds. Tables[0]; 
 
This. Radiobuttonlist1.datatextfield = "ListName"; 
 
This. Radiobuttonlist1.datavaluefield = "id"; 
 
This. Radiobuttonlist1.databind (); 
 
This. Checkboxlist1.datasource = ds. Tables[0]; 
 
This. Checkboxlist1.datatextfield = "ListName"; 
 
This. Checkboxlist1.datavaluefield = "id"; 
 
This. Radiobuttonlist1.databind (); 
 
This. DataBind (); 
 
}//Data binding to Radiobuttonlist,checkboxlist 
 
if (! IsPostBack) 
 
{ 
 
DataSet ds1 = new DataSet (); 
 
using (SqlConnection sqlCnn1 = new SqlConnection (SQL)) 
 
{ 
 
using (SqlCommand sqlCmm1 = Sqlcnn1.createcommand ()) 
 
{ 
 
Sqlcmm1.commandtext = "Select Provinceid,provincename from Province"; 
 
SqlDataAdapter adapter = new SqlDataAdapter (SQLCMM1); 
 
Adapter. Fill (DS1); 
 
This. Dropdownlist1.datasource = DS1. Tables[0]; 
 
This. Dropdownlist1.datatextfield = "Provincename"; 
 
This. Dropdownlist1.datavaluefield = "Provinceid"; 
 
This. Dropdownlist1.databind (); 
 
} 
 
} 
 
} 
 
} 
 
protected void DropDownList1_SelectedIndexChanged (object sender, EventArgs e) 
 
{ 
 
DataSet ds = new DataSet (); 
 
String str = configurationmanager.connectionstrings["strSQL"]. ConnectionString; 
 
using (SqlConnection sqlcnn = new SqlConnection (str)) 
 
{ 
 
using (SqlCommand SQLCMM = Sqlcnn.createcommand ()) 
 
{ 
 
Sqlcmm.commandtext = "Select Cityid,cityname from city where provinceid= '" + this. Dropdownlist1.selectedvalue + "'"; 
 
SqlDataAdapter adapter = new SqlDataAdapter (SQLCMM); 
 
Adapter. Fill (DS); 
 
This. Dropdownlist2.datasource = ds. Tables[0]; 
 
This. Dropdownlist2.datatextfield = "CityName"; 
 
This. Dropdownlist2.datavaluefield = "Cityid"; 
 
This. Dropdownlist2.databind (); 
 
} 
 
} 
 
}//realize two-level linkage between provinces and cities 
 
}