Recursively generate the dropdownlist item set of the news category list

Source: Internet
Author: User

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>
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.