Find Dynamic created RadMenu Item in GridView

4 posts, 0 answers
  1. johnson lim
    johnson lim avatar
    72 posts
    Member since:
    Feb 2010

    Posted 12 May 2010 Link to this post

    Hi, I have a dynamic gridview in which i need to add the RadContextMenu to the gridview cell dynamically.
    Every RadContextMenu may has one or two or more RadMenuItem added to it based on situation.

    I am able to capture which RadContextMenu cause postback in the web pages  ( Request.Form("__EVENTTARGET") ) , however, i need to access to the text of the RadMenuItem then only i can decide whether some control need to be generated based on the RadMenuItem click in the Page load event.
    The purpose of doing so is to avoid the the dynamic control item is generated once in pageload event where postback =true  and generated again on the RadMenuItemClick event.

    Does anyone has idea on this?
  2. T. Tsonev
    T. Tsonev avatar
    2817 posts

    Posted 19 May 2010 Link to this post

    Hi Johnson,

    If I understand correctly, you'd like to skip creating the dynamic control after postback, but still be able to figure out which menu item was clicked.

    The RadMenu will send only the hierarchical index of the clicked item. If you look at the __EVENTARGUMENT field you'll see that it looks like this "0:2" (the third child of the first root item). This information might not be sufficient to figure out what this item is though.

    You can store additional information about the clicked item in a hidden field and use it instead.

    <form id="form1" runat="server">
    <asp:ScriptManager ID="RadScriptManager1" runat="server">
    <script type="text/javascript">
        function itemClicked(s, e) {
            var field = $get("<%= ClickedItemValue.ClientID %>");
            field.value = e.get_item().get_value();
    <script runat="server">
        protected void ClickedItemValue_ValueChanged(object sender, EventArgs e)
            throw new Exception(ClickedItemValue.Value);
        protected void RadMenu1_ItemClick(object sender, RadMenuEventArgs e)
    <asp:HiddenField runat="server" ID="ClickedItemValue" OnValueChanged="ClickedItemValue_ValueChanged"/>
    <telerik:RadMenu ID="RadMenu1" runat="server" OnClientItemClicked="itemClicked" OnItemClick="RadMenu1_ItemClick">
            <telerik:RadMenuItem Text="Sample Item" Value="3.14">

    I hope this helps.

    Sincerely yours,
    Tsvetomir Tsonev
    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.
  3. Kyle
    Kyle avatar
    7 posts
    Member since:
    Apr 2012

    Posted 21 Aug 2014 in reply to T. Tsonev Link to this post

    I have run into the exact issue and have seen the format of the __EVENTARGUMENT as described. My question is.... if the information is not sufficient to figure out which item it is, why does it exist? It seems to me that there IS enough information, there's just no method to call like .FindItemByEventArgument(). There's probably a way to do it but I don't know enough about the internals of the RadMenu to write that method. Maybe Telerik could give us some insight? Thanks.
  4. Dimitar
    Dimitar avatar
    429 posts

    Posted 22 Aug 2014 Link to this post

    Hi Kyle,

    The information stored in the __EVENTARGUMENT  field contains the hierarchical index of the menu item which was clicked. If the items of the RadMenu are available on the sever, based on this hierarchical index the menu item which was clicked is referenced and then passed to the ItemClick event for instance.

    The situation discussed in this forum post is a bit different, since the dynamically created items are not available on the server this hierarchical index won't be helpful, since there is no items collection to search in.


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top