问题描述
我正在aspx.cs中处理Jquery,我已经创建了顶部标题和左侧标题
通过使用Getjson方法,我们需要从数据库调用菜单,因此我创建了像TopMenu和LeftMenu这样的数据库,两个表(TopMenu)包含
(MenuID | MenuName |
1 |首页
2 |产品
和
(LeftMenu)包含
(MenuID | MenuName |
1 |首页
2 |产品
通过使用GetJson方法,我们必须在top标题中的aspx应用程序TopMenu项中调用MenuName,在左标题中的leftMenu名称中调用MenuName,这样我就获得了顶部调用菜单bt我无法访问左侧bt,我在此调用时无法同时访问两个getjson code plz提前帮助我,我应该如何在应用程序中调用菜单
Hi i am working on Jquery in aspx.cs i had created top header and left header
by Using Getjson Method we need to call menus from database so i had created database like TopMenu and LeftMenu two tables( TopMenu) contains
(MenuID|MenuName|
1 |Home
2 |product
and
(LeftMenu) contains
(MenuID|MenuName|
1 |Home
2 |product
by using GetJson method we have to call MenuName in aspx application TopMenu items in topheader and leftMenu names in left header so i had got top calling menus bt i can''t access the left bt i nedd to access both at a time this my calling getjson code plz help me thanks in advance how should i call menus in my application
推荐答案
protected void Page_Load(object sender, EventArgs e)
{
filltree();
}
public void filltree()
{
setConnectionString();
query = "select * from menulist_parent ";
DataSet ds = EmpBal.treeviewBAL(query, conString);
TreeView1.Nodes.Clear();
foreach (DataRow dr in ds.Tables[0].Rows)
{
TreeNode tnparent = new TreeNode();
tnparent.Text = dr["parentname"].ToString();
tnparent.Value = dr["parentid"].ToString();
tnparent.PopulateOnDemand = true;
tnparent.ToolTip = "get one child";
tnparent.SelectAction = TreeNodeSelectAction.SelectExpand;
tnparent.Expand();
tnparent.Selected = true;
TreeView1.Nodes.Add(tnparent);
fillchild(tnparent, tnparent.Value);
}
}
public void fillchild(TreeNode parent,string parentid)
{
setConnectionString();
query = "select * from menulist_child";
DataSet ds = EmpBal.treeviewchildBAL(query, conString);
parent.ChildNodes.Clear();
foreach (DataRow dr in ds.Tables[0].Rows)
{
TreeNode child = new TreeNode();
child.Text = dr["childname"].ToString();
child.Value = dr["childid"].ToString();
child.NavigateUrl = dr["url"].ToString();
if (child.ChildNodes.Count == 0)
{
child.PopulateOnDemand = true;
}
child.ToolTip = "";
child.SelectAction = TreeNodeSelectAction.SelectExpand;
child.CollapseAll();
parent.ChildNodes.Add(child);
}
}
public void setConnectionString()
{
try
{
conString = System.Configuration.ConfigurationManager.ConnectionStrings["masterConnectionString1"].ToString();
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}
<script type="text/javascript">
//ApycomDesing Starts here //
这篇关于如何使用getjson从数据库中获取菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!