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