Recursively generate the dropdownlist item set of the news category list
Public void bindsortdata ()
{
Datatable dt = This. DB. gettable ("select column_id, column_name, column_depth from expro_newstype where column_depth = 1 ");
Sortlist (DT, "0 ");
}
Public void sortlist (datatable DT, string parentid)
{
If (DT! = NULL)
{
Datarow DR = NULL;
String tempcolumnid = "";
String tempcolumn_name = "";
Int tempcolumn_depth = 0;
If (Dt. Rows. Count> 0)
{
For (INT I = 0; I <DT. Rows. Count; I ++)
{
Dr = DT. Rows [I];
Tempcolumnid = convert. tostring (Dr ["column_id"]? "");
Tempcolumn_name = convert. tostring (Dr ["column_name"]? "");
Tempcolumn_depth = int. parse (convert. tostring (Dr ["column_depth"]? ""));
Datatable dttemp = This. DB. gettable ("select column_id, column_name, column_depth from expro_newstype where parent_id = @ parent_id", new system. data. sqlclient. sqlparameter ("@ parent_id", tempcolumnid ));
If (dttemp! = NULL & dttemp. Rows. Count> 0)
{
String tempge = "";
For (Int J = 0; j <tempcolumn_depth-1; j ++)
{
Tempge + = "";
}
This. ddlgtypeid. Items. Add (New listitem (tempge + tempcolumn_name, tempcolumnid ));
Sortlist (dttemp, tempcolumnid );
}
Else
{
String tempge = "";
For (Int J = 0; j <tempColumn_Depth-1; j ++)
{
Tempge + = "";
}
This. ddlgtypeid. Items. Add (New listitem (tempge + tempcolumn_name, tempcolumnid ));
}
}< BR >}< br>
}