radmenu child items

5 posts, 0 answers
  1. Emre
    Emre avatar
    28 posts
    Member since:
    Dec 2011

    Posted 19 Dec 2011 Link to this post

    I have a radmenu with sqldatasource.What I wanna is to get child items value and save to database.I used the code below,but this gets only value of parent items.How can I get the value of child items?
    RadMenu getMenu = Master.FindControl("RadMenu1") as RadMenu;
    getMenu.Items[i].Value;

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 19 Dec 2011 Link to this post

    Hello,

    Try the following code snippet to get the value of child items.
    CS:
    int i;
    for(i=0;i<RadMenu1.SelectedItem.Items.Count;i++)
     {
       string val= RadMenu1.FindItemByValue("2").Items[i].Value;
       //store the value of val in DB.
     }

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Emre
    Emre avatar
    28 posts
    Member since:
    Dec 2011

    Posted 19 Dec 2011 Link to this post

    hello Princy,

    I tried your code snippet but I get the error below.Also I wanna get the all of the value of child items,not selected ones. 

    Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index


  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 19 Dec 2011 Link to this post

    Hello,

    Try the following code snippet.
    CS:
    protected void btn11_Click(object sender, EventArgs e)
     {
        foreach (RadMenuItem itm in RadMenu2.Items)
         {
            string s=  itm.Value; //parent items
            if (itm.Items.Count > 0)
            {
               for (int i = 0; i < itm.Items.Count; i++)
                {
                  string t = itm.Items[i].Value; //child items
                }
           }
        }
    }
     

    Thanks,
    Princy.
  6. Emre
    Emre avatar
    28 posts
    Member since:
    Dec 2011

    Posted 19 Dec 2011 Link to this post

    huge thanks,you saved my hours.It works perfect !
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017