private
void
MakeMenu(Menu menu,
string
menutype,
int
parent)
{
FeatureSet fs = new FeatureSet();
DataTable dt = new DataTable();
int i = 0;
dt=fs.GetByType(menutype,parent);
for (i = 0; i < dt.Rows.Count; i++)
{
MenuItem item = new MenuItem(dt.Rows[i]["menuName"].ToString());
if ((int)dt.Rows[i]["child"] != 0)
{
menu.Items.Add(item);
MakeMenu(item, menutype, (int)dt.Rows[i]["id"]);
}
else
{
item.NavigateUrl = dt.Rows[i]["NavigateUrl"].ToString();
menu.Items.Add(item);
}
}
}
private void MakeMenu(MenuItem menuItem, string menutype, int parent)
{
FeatureSet fs = new FeatureSet();
DataTable dt = new DataTable();
int i = 0;
dt=fs.GetByType(menutype,parent);
for (i = 0; i < dt.Rows.Count; i++)
{
MenuItem item = new MenuItem(dt.Rows[i]["menuName"].ToString());
if ((int)dt.Rows[i]["child"] != 0)
{
menuItem.ChildItems.Add(item);
MakeMenu(item, menutype, (int)dt.Rows[i]["id"]);
}
else
{
item.NavigateUrl = dt.Rows[i]["NavigateUrl"].ToString();
menuItem.ChildItems.Add(item);
}
}
}
通过递归调用生成不限深度的菜单。
{
FeatureSet fs = new FeatureSet();
DataTable dt = new DataTable();
int i = 0;
dt=fs.GetByType(menutype,parent);
for (i = 0; i < dt.Rows.Count; i++)
{
MenuItem item = new MenuItem(dt.Rows[i]["menuName"].ToString());
if ((int)dt.Rows[i]["child"] != 0)
{
menu.Items.Add(item);
MakeMenu(item, menutype, (int)dt.Rows[i]["id"]);
}
else
{
item.NavigateUrl = dt.Rows[i]["NavigateUrl"].ToString();
menu.Items.Add(item);
}
}
}
private void MakeMenu(MenuItem menuItem, string menutype, int parent)
{
FeatureSet fs = new FeatureSet();
DataTable dt = new DataTable();
int i = 0;
dt=fs.GetByType(menutype,parent);
for (i = 0; i < dt.Rows.Count; i++)
{
MenuItem item = new MenuItem(dt.Rows[i]["menuName"].ToString());
if ((int)dt.Rows[i]["child"] != 0)
{
menuItem.ChildItems.Add(item);
MakeMenu(item, menutype, (int)dt.Rows[i]["id"]);
}
else
{
item.NavigateUrl = dt.Rows[i]["NavigateUrl"].ToString();
menuItem.ChildItems.Add(item);
}
}
}