如何在数据库的两个面板中添加数据? [英] how to add data in two panel from database?

查看:82
本文介绍了如何在数据库的两个面板中添加数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在给定的链接 http://www.c-sharpcorner.com/UploadFile/rohatash/creating-dynamic-menu-from-database-sql-server-in-Asp-Net/ [ ^ ]

此链接是动态菜单的一个示例,它位于顶部,我想要的是顶部的两个菜单(垂直)和左侧的另一个(水平)...但问题是,在aspx.cs代码中,上述链接调用面板的作者为

i am usin the given link http://www.c-sharpcorner.com/UploadFile/rohatash/creating-dynamic-menu-from-database-sql-server-in-Asp-Net/[^]
this link is an example of dynamic menu which is on the top and what i want is two menu one on the top(vertical) and other one on left side (horizontal) ... but issue is that in aspx.cs code the author of the above mentioned link call panel as

public partial class _Default : System.Web.UI.Page
{
    SqlConnection con = new SqlConnection("Data Source=(local);Initial Catalog=master;uid=sa; pwd=Micr0s0ft");
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlDataAdapter da = new SqlDataAdapter("Select TechnologyID, TechnologyName, TechnologyURL from Technology", con);
        DataTable dttc = new DataTable();
        da.Fill(dttc);
        HtmlGenericControl main = UList("Menuid", "menu");
        foreach (DataRow row in dttc.Rows)
        {
            da = new SqlDataAdapter("select TechnologyCategoryID,TechnologyCategoryName,TechnologyCategoryURL from TechnologyCategory where TechnologyID=" + row["TechnologyID"].ToString(), con);
            DataTable dtDist = new DataTable();
            da.Fill(dtDist);
            if (dtDist.Rows.Count > 0)
            {
                HtmlGenericControl sub_menu = LIList(row["TechnologyName"].ToString(), row["TechnologyID"].ToString(),  row["TechnologyURL"].ToString());               
                HtmlGenericControl ul = new HtmlGenericControl("ul");              
                foreach (DataRow r in dtDist.Rows)
                {
                    ul.Controls.Add(LIList(r["TechnologyCategoryName"].ToString(), r["TechnologyCategoryID"].ToString(), r["TechnologyCategoryURL"].ToString()));
                }
                sub_menu.Controls.Add(ul);
                main.Controls.Add(sub_menu);
            }
            else
            {
                main.Controls.Add(LIList(row["TechnologyName"].ToString(), row["TechnologyID"].ToString(), row["TechnologyURL"].ToString()));
            }
        }
        Panel1.Controls.Add(main);
    }
    private HtmlGenericControl UList(string id, string cssClass)
    {
        HtmlGenericControl ul = new HtmlGenericControl("ul");
        ul.ID = id;
        ul.Attributes.Add("class", cssClass);
        return ul;
    }
    private HtmlGenericControl LIList(string innerHtml, string rel, string url)
    {      
        HtmlGenericControl li = new HtmlGenericControl("li");
        li.Attributes.Add("rel", rel);
        li.InnerHtml = "" + innerHtml + "";
        return li;
    }
}



现在在哪里调用面板2?


now where to call panel 2 ?

推荐答案

这篇关于如何在数据库的两个面板中添加数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆