Get IsSeparator with Sql Database

2 posts, 0 answers
  1. Jessy Joseph
    Jessy Joseph avatar
    34 posts
    Member since:
    Mar 2010

    Posted 27 May 2010 Link to this post

    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

  2. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 01 Jun 2010 Link to this post

    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.
Back to Top