Asp. NET Infinite classification

Source: Internet
Author: User

began to search the internet for the Unlimited classification of ASP, but ASP.net almost found, and found is also linked with the TreeView.

Find the ASP version of the code there are several, the original is similar to the use of recursive algorithm.

The table structure is as follows:

Table name is classname

ID PRIMARY Key

ID of the parent class corresponding to the SID

ClassName the name of the corresponding category.

Code Snippet One:

1function loadNextType(upid,rank)
2  dim rs
3  set rs="select * from classname where sid="&upid
4  do while not rs.eof
5    loadNextType=loadNextType &rs("ClassName") &"<br>"& string("-",rank) & loadNextType(rs("id"),rank+1)
6    rs.movenext
7  loop
8end function调用时:response.write(loadNextType (0,0))

Another piece of code is the same as the above principle. It's just a way of showing the tree structure.

Code Snippet Two:

1'定义第一级分类
2sub mainfl()
3    dim rs
4    set rs=conn.execute ("select id,F_id,F_name from ClassNae where sid=0 order by id desc")
5    if not rs.eof then
6     do while not rs.eof
7     response.write rs(2) & "<br>"
8     call subfl(rs(0),"  |- ") '循环子级分类
9     rs.movenext
10      if rs.eof then exit do '防上造成死循环
11     loop
12     end if
13end sub
14'定义子级分类
15sub subfl(fid,strdis)
16    dim rs1
17    set rs1=conn.execute("select id,sid,ClassName from ClassName where sid="&fid&" order by id desc")
18    if not rs1.eof then
19    do while not rs1.eof
20    response.write rs1(2) & "<br>"
21    call subfl(rs1(0),"  "&strdis) '递归子级分类
22     rs1.movenext
23    if rs1.eof then
24    rs1.close
25    exit sub
26    end if
27    loop
28    end if
29end sub

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.