Copy Code code as follows: 
 
 
  
 
 
if (! IsPostBack) 
 
{ 
 
First level Category List 
 
This. Dropdownlist1.datasource = DSBB. SelectSubjct1 (); 
 
This. Dropdownlist1.datatextfield = "CName"; 
 
This. Dropdownlist1.datavaluefield = "Ccode"; 
 
This. Dropdownlist1.databind (); 
 
This. DropDownList1.Items.Insert (0,new ListItem ("Please Select First class category", "0")); 
 
This. DropDownList8.Items.Insert (0, New ListItem ("Please select Class two", "0")); 
 
This. DropDownList9.Items.Insert (0,new ListItem ("Please select Class three", "0")); 
 
Level two Category List 
 
 
 
} 
 
<summary> 
 
Binding Level Two classification 
 
</summary> 
 
<param name= "Sender" ></param> 
 
<param name= "E" ></param> 
 
protected void DropDownList1_SelectedIndexChanged (object sender, EventArgs e) 
 
{ 
 
Libs. Database.dbbase DBB = new libs. Database.dbbase (); 
 
If Convert.ToInt32 (this. Dropdownlist1.selectedvalue) = = 0)//Clear list content 
 
{ 
 
This. DropDownList8.Items.Clear (); 
 
This. DropDownList8.Items.Insert (0, New ListItem ("Please select Class two", "0")); 
 
This. DropDownList9.Items.Clear (); 
 
This. DropDownList9.Items.Insert (0, New ListItem ("Please select Class three", "0")); 
 
} 
 
else//Level two category list 
 
{ 
 
This. Dropdownlist8.datasource = DBB. Selectsubjct2 (this. DropDownList1.SelectedValue.Substring (0,2)); 
 
This. Dropdownlist8.datatextfield = "CName"; 
 
This. Dropdownlist8.datavaluefield = "Ccode"; 
 
This. Dropdownlist8.databind (); 
 
This. DropDownList8.Items.Insert (0,new ListItem ("Please select Class two", "0")); 
 
This. DropDownList9.Items.Clear ()//Purge third category 
 
This. DropDownList9.Items.Insert (0, New ListItem ("Please select Class three", "0")); 
 
} 
 
} 
 
<summary> 
 
Binding Level Three classification 
 
</summary> 
 
<param name= "Sender" ></param> 
 
<param name= "E" ></param> 
 
protected void Dropdownlist8_selectedindexchanged (object sender, EventArgs e) 
 
{ 
 
Libs. Database.dbbase dbase = new libs. Database.dbbase (); 
 
This. Dropdownlist9.datasource = Dbase.selectsubject3 (this. DropDownList8.SelectedValue.Substring (0,4)); 
 
This. Dropdownlist9.datatextfield = "CName"; 
 
This. Dropdownlist9.datavaluefield = "Ccode"; 
 
This. Dropdownlist9.databind (); 
 
This. DropDownList9.Items.Insert (0,new ListItem ("Please select Class three", "0")); 
 
} 
 
 
 
 
Dbbase.cs page: 
 
 
  
  Copy Code code as follows: 
 
 
  
 
 
<summary> 
 
Query First Level column 
 
</summary> 
 
<returns></returns> 
 
Public DataSet SelectSubjct1 () 
 
{ 
 
String con = system.configuration.configurationsettings.appsettings["sqlconn"]; 
 
SqlConnection conn = new SqlConnection (Con); 
 
String sqlstr = "Select Kndid, Ccode, CName, clevel from kind WHERE clevel = 1"; 
 
DataSet DST = new DataSet (); 
 
SqlDataAdapter SDA = new SqlDataAdapter (Sqlstr,conn); 
 
Try 
 
{ 
 
Sda. Fill (DST); 
 
return DST; 
 
} 
 
catch (Exception ex) 
 
{ 
 
throw new Exception (ex. message); 
 
} 
 
Finally 
 
{ 
 
Conn. Close (); 
 
} 
 
} 
 
<summary> 
 
Query level two column content 
 
</summary> 
 
<param name= "Ccode" ></param> 
 
<returns></returns> 
 
Public DataSet Selectsubjct2 (string ccode) 
 
{ 
 
String conn1 = system.configuration.configurationsettings.appsettings["Sqlconn"]; 
 
SqlConnection conn = new SqlConnection (CONN1); 
 
String sqqq = "Select Kndid,ccode,cname,clevel from kind where clevel = 2 and ccode like '" + ccode + "%"; 
 
DataSet DSS = new DataSet (); 
 
SqlDataAdapter SDD = new SqlDataAdapter (Sqqq,conn); 
 
Try 
 
{ 
 
Sdd. Fill (DSS); 
 
return DSS; 
 
} 
 
catch (Exception ex) 
 
{ 
 
throw new Exception (ex. message); 
 
} 
 
Finally 
 
{ 
 
Conn. Close (); 
 
} 
 
} 
 
<summary> 
 
Query level three column content 
 
</summary> 
 
<param name= "CDE" ></param> 
 
<returns></returns> 
 
Public DataSet selectsubject3 (string cde) 
 
{ 
 
String conn2 = system.configuration.configurationsettings.appsettings["Sqlconn"]; 
 
SqlConnection conn = new SqlConnection (CONN2); 
 
String sqq = "Select Kndid,ccode,cname,clevel from Kind where clevel = 3 and ccode like '" + CDE + "%"; 
 
DataSet DST = new DataSet (); 
 
SqlDataAdapter sdaa = new SqlDataAdapter (Sqq,conn); 
 
Try 
 
{ 
 
Sdaa. Fill (DST); 
 
return DST; 
 
} 
 
catch (Exception ex) 
 
{ 
 
throw new Exception (ex. message); 
 
} 
 
Finally 
 
{ 
 
Conn. Close (); 
 
} 
 
} 
 
 
 
Note: dropdownlist1_selectedindexchanged event, autopostback= "True"