我想从数据库中绑定菜单...我该怎么办? [英] I want to bind the menu from database...how can i?
本文介绍了我想从数据库中绑定菜单...我该怎么办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
private void loaddata()
{
string strsql = "select * from dbo.MenuTable";
// string strsql = "RadMenu1_ItemClick";
SqlCommand cmd = new SqlCommand(strsql, sqlconn);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sqlconn.Open();
adp.Fill(dt);
sqlconn.Close();
RadMenu1.DataSource = dt;
RadMenu1.DataTextField = dt.Columns["Solutions"].ToString() + dt.Columns["Home"].ToString();
//RadMenu1.DataTextField = "Solutions" + "Home";
RadMenu1.DataValueField = "Solutions" + "Home";
RadMenu1.DataBind();
}
我想从数据库绑定菜单...我该怎么办?
I want to bind the menu from database...how can i??
推荐答案
^ ]
在ASP.NET 2.0中填充菜单控件-使用不同的数据源 [如何使用asp.net将菜单与sqlserver数据库绑定 [ ^ ]
Binding Menu Control With Database[^]
Populating Menu Control in ASP.NET 2.0 - using different data sources[^]
how to bind menu with sqlserver database using asp.net[^]
首先,从程序中学习如何构建菜单以及如何访问数据库.希望您已经知道该怎么做.
认为菜单就像一棵树.有物品,物品有孩子.父母可以有很多孩子.但是,想一下就倒过来.孩子有父母.一个孩子只能有一个父母,不能再有一个.所以,这就是全部.
制作表格:{menu item ="} {parent}.菜单的根将具有父级null.就这样.父级应该是一个外键,它指向同一表的主键.
如果您使用MSSQL或Oracle,则可以进行递归查询,这就是您所需要知道的.
First of all, learn how to build menu and how to access databases, from your program. Hope you already know how to do that.
Think the menu as a tree. There are items, and items have children. A parent can have many children. But think a bit reverse. Children have parents. A child can have exactly one parent, no more. So, this is all.
Make the table: {menu item=""} {parent}. The root of menu will have parent null. That''s all. The parent should be a foreign key, which points to the primary key of same table.
If you use MSSQL or Oracle, you can make recursive queries, that''s all you have to know.
这篇关于我想从数据库中绑定菜单...我该怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文