我做的是杂志网站,我想实现杂志的发布,一级目录:期刊号,二级目录:栏目,三级目录:文章。首先栏目是动态的,我希望栏目有一部分“人生”、“情感”等是本来就有,但是有时候也可以添加栏目,但是我不知道怎么保存期刊号和栏目号之间的关系,还有在后台显示文章列表这一块,怎么显示?因为涉及到三个表,最重要的是如果修改栏目的信息,对文章的影响该如何实现? 

解决方案 »

  1.   

    本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/ws_hgo/archive/2009/11/20/4842026.aspxnamespace XR.Web   
    {   
        using System;   
        using System.Collections;   
        using System.Configuration;   
        using System.Data;   
        using System.Web;   
        using System.Web.Security;   
        using System.Web.UI;   
        using System.Web.UI.HtmlControls;   
        using System.Web.UI.WebControls;   
        using System.Web.UI.WebControls.WebParts;   
        using System.Data.Sql;   
        using System.Data.SqlClient;   
        public partial class Default2 : System.Web.UI.Page   
        {   
            DataTable Tables = new DataTable();   
            DataColumn DC = new DataColumn();   
            DataRow DR;   
            ProductCategoryBLL Category = new ProductCategoryBLL();    
            protected void Page_Load(object sender, EventArgs e)   
            {   
                DataTable DT = Category.GetDataTable("YLProductCategory", 0);   
                CreateDataTable();   
                GetTree(DT, 0, 0);   
                DropDownList1.DataSource = Tables;   
                DropDownList1.DataTextField = "Title";   
                DropDownList1.DataValueField = "ID";   
                DropDownList1.DataBind();   
            }   
            public void GetTree(DataTable DT,int PID,int Depth)   
            {   
                DataView DV = DT.DefaultView;   
                DV.RowFilter = "ParentID=" + PID;   
                string str = string.Empty;   
                if (Depth == 0)   
                {   
                    str = "";              
                }   
                else if (Depth == 1)   
                {   
                    str = "├";   
                }   
                else  
                {   
                    for (int i = 0; i < Depth; i++)   
                    {   
                        str =str+"├" + "" + "-";   
                    }   
                }   
                foreach (DataRowView Drv in DV)   
                {   
                    int ID = int.Parse(Drv["ID"].ToString());   
                    string Title = Drv["Title"].ToString();   
                    int ParentID = int.Parse(Drv["ParentID"].ToString());   
                    int Dep = int.Parse(Drv["Depth"].ToString());   
                    DR = Tables.NewRow();   
                    DR["ID"] = ID;   
                    DR["Title"] = str + Title;   
                    DR["ParentID"] = ParentID;   
                    DR["Depth"] = Dep;   
                    Tables.Rows.Add(DR);   
                    int n = Dep;   
                    n++;   
                    GetTree(DT,ID, n);   
                }   
            }   
            public void CreateDataTable()   
            {   
                DC = new DataColumn();   
                DC.ColumnName = "ID";   
                DC.DataType = System.Type.GetType("System.Int32");   
                Tables.Columns.Add(DC);   
      
                DC = new DataColumn();   
                DC.ColumnName = "Title";   
                DC.DataType = System.Type.GetType("System.String");   
                Tables.Columns.Add(DC);   
      
                DC = new DataColumn();   
                DC.ColumnName = "ParentID";   
                DC.DataType = System.Type.GetType("System.Int32");   
                Tables.Columns.Add(DC);   
      
                DC = new DataColumn();   
                DC.ColumnName = "Depth";   
                DC.DataType = System.Type.GetType("System.Int32");   
                Tables.Columns.Add(DC);   
            }   
        }   
      
    }  
      

  2.   

    不需要三个表吧?一个就够了。菜单树即可解决。犹如CSND的目录树
      

  3.   

    Create table Journals 
    (JID int IDENTITY (1, 1) primary key, 
    Jname varchar(20) unique, 
    Jimage varchar(100), 
    state varchar(20) default '建设中', 
    Jtime datetime null,) 
    Create table Lanmu 
    (LID int IDENTITY (1, 1) primary key, 
    CNAME varchar(20) not null, 
    ) Create table Articles 
    (ARID varchar(9) primary key, 
    ATitle varchar(20) not null, 
    Acontent text not null, 
    Adate Datetime not null, 
    LID int not null, 
    AID  varchar(20) not null, 
    JID int not null, 
    EID int not null, 
    Foreign key(AID) references Authors(AID), 
    Foreign key(CID) references Lanmu(CID), 
    Foreign key(JID) references Journals(JID), 
    Foreign key(EID) references Editors(EID) 
    )
      

  4.   

    应该是树状结构,使用treeview递归绑定数据