Copy codeThe Code is as follows:
Private string toadd = "inline". <BR> private void GetArticleCategory (string pid)
{
SqlConnection conn = new SqlConnection ("server =.; database = test; uid = sa; pwd = ;");
String SQL = "select Articlesgroup_id, Groupname from Articlesgroup where Articlesgroup_parent_id = @ pid order by Groupname ";
SqlCommand cmd = new SqlCommand (SQL, conn );
SqlParameter Pid = new SqlParameter ("@ pid", SqlDbType. Int );
Pid. Value = pid;
Cmd. Parameters. Add (Pid );
Conn. Open ();
SqlDataReader sdr = cmd. ExecuteReader ();
While (sdr. Read ())
{
This. DropDownList1.Items. Add (new ListItem (toadd + "" + sdr [1]. ToString (), sdr [0]. ToString ()));
Toadd + = "-Example ";
This. GetArticleCategory (sdr [0]. ToString ());
Toadd = toadd. Substring (0, toadd. Length-2 );
}
Sdr. Close ();
Conn. Close ();
}
Call in Page_Load
Program code
Copy codeThe Code is as follows:
Protected void Page_Load (object sender, EventArgs e)
{
This. keyword. Attributes. Add ("onfocus", "if (this. value = 'key key key') {this. value = ''};");
If (! Page. IsPostBack)
{
This. GetArticleCategory ("0 ");
}
This. DropDownList1.Items. Insert (0, new ListItem ("Search All", "all "));
}