ASP.net 折叠菜单怎么绑定数据库

ASP.net折叠菜单怎么绑定数据库... ASP.net 折叠菜单怎么绑定数据库 展开
 我来答
匿名用户
2013-05-07
展开全部
<cc1:Accordion ID="Accordion1" runat="server" HeaderCssClass="accordionHeader" ContentCssClass="accordionContent" FadeTransitions="true" >
<Panes>

</Panes>
</cc1:Accordion>

2:后台的代码

/// <summary>
/// 绑定滑动菜单
/// </summary>
private void acc1Bind()
{
//获取第一层目录
List<Tucue.ShopModel.GoodsType> li1 = GetMenu("0");
//循环第一层目录
foreach (Tucue.ShopModel.GoodsType goodtype in li1)
{

#region//绑定搜索下拉列表
ListItem lvi = new ListItem();
lvi.Text = goodtype.TypeName;
lvi.Value = goodtype.Cid;
ddlShopType.Items.Add(lvi);
#endregion

AjaxControlToolkit.AccordionPane ap1 = new AjaxControlToolkit.AccordionPane();
System.Web.UI.WebControls.HyperLink lblParatMenu = new System.Web.UI.WebControls.HyperLink();
lblParatMenu.Text =""+ goodtype.TypeName;
lblParatMenu.Font.Bold = false;
//lblParatMenu.ForeColor = Color.White;
//给滑动菜单添加标题
ap1.HeaderContainer.Controls.Add(lblParatMenu);
//设定标题ID
ap1.HeaderContainer.ID = goodtype.Cid.ToString();
//根据第一层目录ID获取第二层目录
List<Tucue.ShopModel.GoodsType> li2 = GetMenu(goodtype.Cid);

//循环第二层目录
foreach (Tucue.ShopModel.GoodsType goodtype2 in li2)
{

//添加第二层目录
System.Web.UI.WebControls.HyperLink lblParatMenu2 = new System.Web.UI.WebControls.HyperLink();
lblParatMenu2.Text =" "+ goodtype2.TypeName+"<p>";
System.Web.UI.WebControls.Image img1 = new System.Web.UI.WebControls.Image();
if (lbltypeId.Text == null||lbltypeId.Text.Equals(""))
{
img1.ImageUrl = "images/134-1.gif";
}
else
{
if (goodtype2.Cid.Equals(lbltypeId.Text))
{
img1.ImageUrl = "images/134.gif";
}
else
{
img1.ImageUrl = "images/134-1.gif";
}
}

// lblParatMenu2.ForeColor = "#0066FF";
lblParatMenu2.ForeColor=Color.FromName("#2d63cf");
lblParatMenu2.NavigateUrl = "Default.aspx?type="+goodtype2.Cid.ToString();
ap1.ContentContainer.Controls.Add(img1);
ap1.ContentContainer.Controls.Add(lblParatMenu2);
ap1.ContentContainer.ID = goodtype2.Cid.ToString();
}
//将目录内容添加到Accordion控件中
Accordion1.Panes.Add(ap1);
}
}
匿名用户
2013-05-07
展开全部
折叠菜单? 是treeview吗 我是这样写的,希望能帮到你:前台代码:<asp:TreeView ID="TreeView1" runat="server" Height="423px" Width="169px" Target="iframe1" ExpandDepth="0">
<NodeStyle CssClass="link1" />

</asp:TreeView>后台代码 DataBase db = new DataBase(); //实例化一个数据库类
public void bind()
{

DataTable dt = db.Sel_Protype();//读取一级类别

for (int i = 0; i < dt.Rows.Count; i++) //绑定一级类别
{
TreeNode node = new TreeNode(dt.Rows[i]["P_name"].ToString());
this.TreeView1.Nodes.Add(node);
int NodeId=Convert.ToInt32(dt.Rows[i]["P_ID"]);//.ToString();
node.NavigateUrl = "ProClassEdit.aspx?id=" + NodeId;
node.Target = "iframe1";
DataTable dt2 = db.Sel_Protype2(NodeId); for (int j = 0; j < dt2.Rows.Count; j++) //绑定二级类别
{
TreeNode node2 = new TreeNode(dt2.Rows[j]["P_name"].ToString());
node.ChildNodes.Add(node2);
int NodeID2 = Convert.ToInt32(dt2.Rows[j]["P_ID"]);
node2.NavigateUrl = "ProClassEdit.aspx?id=" + NodeID2;
node2.Target = "iframe1"; DataTable dt3 = db.Sel_Protype2(NodeID2); for (int k = 0; k < dt3.Rows.Count; k++) //绑定三级类别
{
TreeNode node3 = new TreeNode(dt3.Rows[k]["P_name"].ToString());
node2.ChildNodes.Add(node3);
int Nodeid3 = Convert.ToInt32(dt3.Rows[k]["P_ID"]);
node3.NavigateUrl = "ProClassEdit.aspx?id=" + Nodeid3;
node3.Target = "iframe1";
}
}
}
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式