Example #1
0
        private void ShowChapterNode(int intSubjectID, TreeNode treenode)
        {
            string         strConn = ConfigurationSettings.AppSettings["strConn"];
            SqlConnection  SqlConn = new SqlConnection(strConn);
            SqlDataAdapter SqlCmd  = new SqlDataAdapter("select * from ChapterInfo where SubjectID=" + intSubjectID + " order by ChapterID asc", SqlConn);
            DataSet        SqlDS   = new DataSet();

            SqlCmd.Fill(SqlDS, "ChapterInfo");

            for (int i = 0; i < SqlDS.Tables["ChapterInfo"].Rows.Count; i++)
            {
                TreeNode node = new TreeNode();
                node.Target   = "studymain";
                node.ImageUrl = "../images/folder.gif";
                node.Text     = SqlDS.Tables["ChapterInfo"].Rows[i]["ChapterName"].ToString();
                node.Value    = "JoinStudyList.aspx?SubjectID=" + SqlDS.Tables["ChapterInfo"].Rows[i]["SubjectID"].ToString() + "&ChapterID=" + SqlDS.Tables["ChapterInfo"].Rows[i]["ChapterID"].ToString() + "&SectionID=" + Convert.ToString(0) + "";
                //node.Value=SqlDS.Tables["ChapterInfo"].Rows[i]["SubjectID"].ToString()+"."+SqlDS.Tables["ChapterInfo"].Rows[i]["ChapterID"].ToString()+".0."+SqlDS.Tables["ChapterInfo"].Rows[i]["CreateUserID"].ToString();
                node.Expanded = true;
                treenode.ChildNodes.Add(node);
                ShowSectionNode(Convert.ToInt32(SqlDS.Tables["ChapterInfo"].Rows[i]["SubjectID"]), Convert.ToInt32(SqlDS.Tables["ChapterInfo"].Rows[i]["ChapterID"]), node);
            }
            TreeViewBook.DataBind();

            SqlConn.Dispose();
        }
Example #2
0
        private void ShowSubjectNode(string strSql)
        {
            string         strConn = ConfigurationSettings.AppSettings["strConn"];
            SqlConnection  SqlConn = new SqlConnection(strConn);
            SqlDataAdapter SqlCmd  = new SqlDataAdapter(strSql, SqlConn);
            DataSet        SqlDS   = new DataSet();

            SqlCmd.Fill(SqlDS, "SubjectInfo");

            //添加根节点
            TreeViewBook.Nodes.Clear();
            for (int i = 0; i < SqlDS.Tables["SubjectInfo"].Rows.Count; i++)
            {
                TreeNode node = new TreeNode();
                node.ImageUrl = "../images/folder.gif";
                node.Text     = SqlDS.Tables["SubjectInfo"].Rows[i]["SubjectName"].ToString();
                node.Target   = "studymain";
                node.Value    = "JoinStudyList.aspx?SubjectID=" + SqlDS.Tables["SubjectInfo"].Rows[i]["SubjectID"].ToString() + "&ChapterID=" + Convert.ToString(0) + "&SectionID=" + Convert.ToString(0) + "";
                //node.Value=SqlDS.Tables["SubjectInfo"].Rows[i]["SubjectID"].ToString()+".0.0.0";
                node.Expanded = true;
                TreeViewBook.Nodes.Add(node);
                ShowChapterNode(Convert.ToInt32(SqlDS.Tables["SubjectInfo"].Rows[i]["SubjectID"]), node);
            }
            TreeViewBook.DataBind();

            SqlConn.Dispose();
        }