// input:
// dataRows - [in] Child Rows
// dataRel - [in] Data Relation
// webMenuGroup - [in] WebMenu Group
//
// output:
// none
//
public void AddMenuItems(DataRow[] dataRows, DataRelation dataRel, Coalesys.WebMenu.Group webMenuGroup)
{
Coalesys.WebMenu.Item csMenuItem;
Coalesys.WebMenu.Group csNestedMenuGroup;
DataRow[] drChildren;
foreach(DataRow dbMenuItem in dataRows)
{
csMenuItem = webMenuGroup.Items.Add();
csMenuItem.Caption = dbMenuItem["Caption"].ToString();
csMenuItem.URL = dbMenuItem["URL"].ToString();
if (dbMenuItem["Enable"].ToString()=="True" )
{
csMenuItem.Enabled=true;
}
else
{
csMenuItem.Enabled=false;
}
// check if this Item has children of it's own
drChildren = dbMenuItem.GetChildRows(dataRel);
// if so, create a group for the children and reenter this function.
if(drChildren.Length > 0)
{
csNestedMenuGroup = csMenuItem.AddGroup();
AddMenuItems(drChildren, dataRel, csNestedMenuGroup);
}
}
}
}
效果图如下: