This is a migrated thread and some comments may be shown as answers.

Get IsSeparator with Sql Database

1 Answer 28 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Jessy Joseph
Top achievements
Rank 1
Jessy Joseph asked on 27 May 2010, 10:06 PM
Hi,

In my project I am getting the menu items programaticaly from the sql server. The problem I am facing is, how to add IsSeperator  in the database and call in the code?


aspx file

 

<telerik:RadMenu ID="radMenu" runat="server" EnableRoundedCorners="true" EnableShadows="true"

 

 

Skin="Office2007" >

 

 

</telerik:RadMenu>

 

---------------------------------------------------------
cs file

private

 

void buildMenu()

 

{

 

OleDbConnection dbCon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("~/MenusiteMap.mdb"));

 

dbCon.Open();

 

OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM Sitemap_Menu ORDER BY MenuId", dbCon);

 

 

DataSet ds = new DataSet();

 

adapter.Fill(ds);

ds.Relations.Add(

"NodeRelation", ds.Tables[0].Columns["MenuId"], ds.Tables[0].Columns["ParentId"]);

 

 

foreach (DataRow dbRow in ds.Tables[0].Rows)

 

{

 

if (dbRow.IsNull("ParentId"))

 

{

 

RadMenuItem newItem = CreateItem(dbRow);

 

radMenuAcc.Items.Add(newItem);

PopulateSubMenu(dbRow, newItem);

}

}

}

 

 

private RadMenuItem CreateItem(DataRow dbRow)

 

{

 

RadMenuItem item = new RadMenuItem();

 

item.Text = dbRow[

"Text"].ToString();

 

item.NavigateUrl = dbRow[

"NavigateUrl"].ToString();

 

item.ImageUrl = dbRow[

"IconImage"].ToString();

 

item.HoveredImageUrl = dbRow[

"HoverIconImage"].ToString();

 

 

return item;

 

}

 

private void PopulateSubMenu(DataRow dbRow, RadMenuItem item)

 

{

 

foreach (DataRow childRow in dbRow.GetChildRows("NodeRelation"))

 

{

 

RadMenuItem childItem = CreateItem(childRow);

 

item.Items.Add(childItem);

PopulateSubMenu(childRow, childItem);

}

}
----------------------------------------------------
database fields
MenuID, Text, ParentID,Navigateurl,IconImage,HoverIconImage
--------------------------------------------------
Thanks.
Jessy

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 01 Jun 2010, 05:10 PM
Hello Jessy,

Please, see this help topic on databinding RadMenu. More specifically, scroll down to
 
3.Create an ItemDataBound event handler to set additional properties on the menu items:


Greetings,
Peter
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Menu
Asked by
Jessy Joseph
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or