CopyCode The 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 Code the code is as follows: protected void page_load (Object sender, eventargs e)
{< br> This. keyword. attributes. add ("onfocus", "If (this. value = 'key key key') {This. value = ''};");
If (! Page. ispostback)
{< br> This. getarticlecategory ("0");
}< br> This. dropdownlist1.items. insert (0, new listitem ("search all", "all");
}