Hi !
Please help me how to binding a UltraWebMenu from DataSet with struct "ID - ParentID". Thanks !
The formatting got screwed here is better version.
private void LoadMenuItems()
{
DataSet dsMenuItems = new DataSet();
try
//this method gets you the 2 datatables in the dataset
GetMenu(ref dsMenuItems);
dsMenuItems.DataSetName = "Menu";
dsMenuItems.Tables[0].TableName = "MainMenu";
dsMenuItems.Tables[1].TableName = "SubMenu";
dsMenuItems.Relations.Add("RELATION", dsMenuItems.Tables[0].Columns["MAINMENUITEMID"],
dsMenuItems.Tables[1].Columns["MAINMENUITEMID"], true);
//populate the menu here
if (dsMenuItems != null)
UltraWebMenu1.DataSource = dsMenuItems;//.Tables[0].DefaultView;
//UltraWebMenu1.Levels[0].TargetUrlName = "NAVIGATIONURL";
UltraWebMenu1.Levels[0].ColumnName = "MAINMENUITEMNAME";
UltraWebMenu1.Levels[0].LevelKeyField = "MAINMENUITEMID";
UltraWebMenu1.Levels[0].RelationName = "RELATION";
UltraWebMenu1.Levels[1].TargetUrlName = "NAVIGATIONURL";
UltraWebMenu1.Levels[1].ColumnName = "SUBMENUITEMNAME";
UltraWebMenu1.Levels[1].LevelKeyField = "SUBMENUITEMID";
UltraWebMenu1.DataMember = dsMenuItems.Tables[0].TableName;
UltraWebMenu1.DataBind();
}
catch (Exception ex)
Here it is if you want to bind a dataset.
DataSet
dsMenuItems = new DataSet();
try{
GetMenu(
ref dsMenuItems);
dsMenuItems.DataSetName =
"Menu";
dsMenuItems.Tables[0].TableName =
"MainMenu";
dsMenuItems.Tables[1].TableName =
"SubMenu";
dsMenuItems.Relations.Add(
"RELATION", dsMenuItems.Tables[0].Columns["MAINMENUITEMID"], sMenuItems.Tables[1].Columns["MAINMENUITEMID"], true);
UltraWebMenu1.DataSource = dsMenuItems;
UltraWebMenu1.Levels[0].LevelKeyField =
"MAINMENUITEMID";
UltraWebMenu1.Levels[0].RelationName =
"RELATION";
UltraWebMenu1.Levels[1].TargetUrlName =
"NAVIGATIONURL";
UltraWebMenu1.Levels[1].ColumnName =
"SUBMENUITEMNAME";
UltraWebMenu1.Levels[1].LevelKeyField =
"SUBMENUITEMID";
i have been used binding of UltraWebTree for Menu and it work fine.
here is my DataTable with columns "ID - ParentID - Name" and a Relations as
DataRelation dr = new DataRelation("re", ds.Tables[0].Columns["ID"], ds.Tables[0].Columns["ParentID"], false);
and this is code for binding:
//assign the datasource DataView dv = ds.Tables[0].DefaultView; dv.RowFilter = "ParentID=0"; this.UltraWebMenu1.DataSource = dv; //set up the levels to use the relation for (int i = 0; i < 50; i++) { this.UltraWebMenu1.Levels[i].ColumnName = "Name"; this.UltraWebMenu1.Levels[i].LevelImage = "../../../ig_common/images/dir.png"; this.UltraWebMenu1.Levels[i].RelationName = "r1"; this.UltraWebMenu1.Levels[i].LevelKeyField = "ID"; } //databind this.UltraWebMenu1.DataBind(); UltraWebMenu1.WebMenuTarget = Infragistics.WebUI.UltraWebNavigator.WebMenuTarget.HorizontalMenu;