radcontextmenu Inside RadMenuItem record databind

7 posts, 0 answers
  1. mohamed
    mohamed avatar
    311 posts
    Member since:
    Mar 2011

    Posted 03 Sep 2012 Link to this post

    I want bind record in radmenuitem through server side take from data base ,
    And also i want find in page load ,

      
    <MasterTableView  AllowFilteringByColumn="true" IsFilterItemExpanded="false" HeaderStyle-Width="200px" ItemStyle-Width="200px" CommandItemDisplay="Top" DataKeyNames="lid"  ClientDataKeyNames="lid" Width="100%">
               <CommandItemTemplate>           
                   <div style="padding: 5px 0px 5px 7px; text-align: left; font-weight:bold;">
                   <span class="gridHeaderTitle">
                       <i><telerik:RadCodeBlock ID="RadCodeBlock2" runat="server"><%= Resources.People.People_List %></telerik:RadCodeBlock></i>
                       </span>
                   <table>
                   <tr>
                   <td align="left">
                   <!--#include file = ../Shared/gridHeaderTemplates_Layout.htm-->
                   </td>
                   <td>
                   <telerik:radbutton enablesplitbutton="true" id="SplitButton" autopostback="false"
                       runat="server" text="Transfer Item" onclientclicked="OnClientClicked">
                   </telerik:radbutton>           
                   <telerik:radcontextmenu id="RadContextMenu1" runat="server" OnClientItemClicked="OnClientItemClicked">
                   <Items>
                       <telerik:RadMenuItem id="Temp" >
                       </telerik:RadMenuItem>
                   </Items>
               </telerik:radcontextmenu>
                   </td>
                   </tr>
                   </table>                 
                   </div>
                    
               </CommandItemTemplate>
               <Columns>                                                         
                   <telerik:GridClientSelectColumn HeaderStyle-Width="6%" HeaderStyle-HorizontalAlign="Center">
                       <ItemStyle HorizontalAlign="Center" BorderStyle ="None" />
                   </telerik:GridClientSelectColumn>                          
               </Columns>               
           </MasterTableView>


    Thanks Advance,
    Mohamed.
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 03 Sep 2012 Link to this post

    Hi,

    Try the following code to populate RadContextMenu.
    C#:
    protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.Item is GridCommandItem)
        {
          GridCommandItem item = (GridCommandItem)e.Item;
          RadContextMenu RadContextMenu1 = (RadContextMenu)item.FindControl("RadContextMenu1");
          RadContextMenu1.DataSourceID = "SqlDataSource2";
          RadContextMenu1.DataTextField = "name";
          RadContextMenu1.DataFieldParentID = "parent";
          RadContextMenu1.DataFieldID = "id";
        }
    }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. mohamed
    mohamed avatar
    311 posts
    Member since:
    Mar 2011

    Posted 03 Sep 2012 Link to this post

    Thanks for your reply shinu,
    it's not bind anything

    int pep = Convert.ToInt16(Globals.Entity.People);
                    using (var db = new TBSHelpDeskDataContext(Globals.strCon))
                    {
                        var md = (from a in db.Templates where a.EntityID == pep select new { a.EntityID, a.Template_Name }).ToList();
     
                        GridCommandItem item = (GridCommandItem)e.Item;
                        RadContextMenu RadContextMenu1 = (RadContextMenu)item.FindControl("RadContextMenu1");
                        RadContextMenu1.DataSource = md;
                        RadContextMenu1.DataTextField = "Template_Name";
                        //RadContextMenu1.DataFieldParentID = "parent";
                        RadContextMenu1.DataFieldID = "EntityID";
                        RadContextMenu1.DataBind();
                    }


    Thanks advance,
    Mohamed.
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 04 Sep 2012 Link to this post

    HJi,

    Unfortunately I cannot replicate the issue at my end. Here is the full code code that I tried based on your scenario.
    aspx:
    <telerik:RadGrid  ID="RadGrid1" DataSourceID="SqlDataSource1" runat="server" AutoGenerateColumns="Fals OnItemDataBound="RadGrid1_ItemDataBound">
     <MasterTableView CommandItemDisplay="Top">
       <CommandItemTemplate>          
         <telerik:radcontextmenu id="RadContextMenu1" runat="server"></telerik:radcontextmenu>
       </CommandItemTemplate>
        <Columns>
         . . . .
        </Columns>
     </MasterTableView>
    </telerik:RadGrid>
    C#:
    protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.Item is GridCommandItem)
        {
          GridCommandItem item = (GridCommandItem)e.Item;
          RadContextMenu RadContextMenu1 = (RadContextMenu)item.FindControl("RadContextMenu1");
          RadContextMenu1.DataSourceID = "SqlDataSource2";
          RadContextMenu1.DataTextField = "name";
          RadContextMenu1.DataFieldParentID = "parent";
          RadContextMenu1.DataFieldID = "id";
        }
    }
    Also check the following help documentation which explains data binding in Radmenu.
    Data Binding Overview

    Thanks,
    Shinu.
  6. New
    New  avatar
    25 posts
    Member since:
    Jul 2012

    Posted 04 Sep 2012 Link to this post

    Thanks For your reply shinu,

        </form>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:DBConnectionString %>"
            SelectCommand="select * from Templates where EntityID=3"></asp:SqlDataSource>
    </body>
    </html>

    protected void RadGrid_OnItemDataBound(object sender, GridItemEventArgs e)
            {
                if (e.Item is GridCommandItem)
                {
                    //GridCommandItem commandItem = (GridCommandItem)e.Item;
                    RadComboBox ppl_templates = (RadComboBox)e.Item.FindControl("cmb_templates");
                    ppl_templates.DataSource = EntityTemplates.getTemplates(Globals.Entity.People);
                    ppl_templates.SelectedValue = EntityTemplates.getDefaultUserTemplate(Globals.Entity.People).ToString();
                    ppl_templates.DataBind();
     
     
                    //GridCommandItem item = (GridCommandItem)e.Item;
                    //RadContextMenu RadContextMenu1 = (RadContextMenu)item.FindControl("RadContextMenu1");               
                    //RadContextMenu1.DataSource = DbClient.GetList<Template>("EntityID == " + Convert.ToInt32(Globals.Entity.People));
                    //RadContextMenu1.DataTextField = "Template_Name";
                    //RadContextMenu1.DataValueField = "TemplateID";               
                    //RadContextMenu1.DataBind();
     
                    GridCommandItem item = (GridCommandItem)e.Item;
                    RadContextMenu RadContextMenu1 = (RadContextMenu)item.FindControl("RadContextMenu1");
                    RadContextMenu1.DataSourceID = "SqlDataSource2";
                    RadContextMenu1.DataTextField = "Template_Name";
                    RadContextMenu1.DataFieldParentID = "EntityID";
                    RadContextMenu1.DataFieldID = "TemplateID";

    Not bind anything

    Thanks Advance ,
    Mohamed .
  7. mohamed
    mohamed avatar
    311 posts
    Member since:
    Mar 2011

    Posted 04 Sep 2012 Link to this post

    Thanks For your reply shinu,

    </form>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:DBConnectionString %>"
            SelectCommand="select * from Templates where EntityID=3"></asp:SqlDataSource>
    </body>
    </html>

    protected void RadGrid_OnItemDataBound(object sender, GridItemEventArgs e)
            {
                if (e.Item is GridCommandItem)
                {
                    //GridCommandItem commandItem = (GridCommandItem)e.Item;
                    RadComboBox ppl_templates = (RadComboBox)e.Item.FindControl("cmb_templates");
                    ppl_templates.DataSource = EntityTemplates.getTemplates(Globals.Entity.People);
                    ppl_templates.SelectedValue = EntityTemplates.getDefaultUserTemplate(Globals.Entity.People).ToString();
                    ppl_templates.DataBind();
      
      
                    //GridCommandItem item = (GridCommandItem)e.Item;
                    //RadContextMenu RadContextMenu1 = (RadContextMenu)item.FindControl("RadContextMenu1");              
                    //RadContextMenu1.DataSource = DbClient.GetList<Template>("EntityID == " + Convert.ToInt32(Globals.Entity.People));
                    //RadContextMenu1.DataTextField = "Template_Name";
                    //RadContextMenu1.DataValueField = "TemplateID";              
                    //RadContextMenu1.DataBind();
      
                    GridCommandItem item = (GridCommandItem)e.Item;
                    RadContextMenu RadContextMenu1 = (RadContextMenu)item.FindControl("RadContextMenu1");
                    RadContextMenu1.DataSourceID = "SqlDataSource2";
                    RadContextMenu1.DataTextField = "Template_Name";
                    RadContextMenu1.DataFieldParentID = "EntityID";
                    RadContextMenu1.DataFieldID = "TemplateID";

    Not bind anything in RadContextMenu,
    Reply Soon

    Thanks Advance ,
    Mohamed .

  8. mohamed
    mohamed avatar
    311 posts
    Member since:
    Mar 2011

    Posted 05 Sep 2012 Link to this post

    Please Check that Lnk
    http://demos.telerik.com/aspnet-ajax/button/examples/splitbutton/defaultcs.aspx

    <telerik:RadButton EnableSplitButton="true" ID="SplitButton" AutoPostBack="false"
                    runat="server" Text="Transfer Item" OnClientClicked="OnClientClicked">
                </telerik:RadButton>
                <telerik:RadContextMenu ID="RadContextMenu1" runat="server" OnClientItemClicked="OnClientItemClicked">
                    <Items>
                        <telerik:RadMenuItem Text="Transfer Right">
                        </telerik:RadMenuItem>
                        <telerik:RadMenuItem Text="Transfer Left">
                        </telerik:RadMenuItem>
                    </Items>
                </telerik:RadContextMenu>
    I'm Taking This Part and i put in to my form nothing has list out ,
    What's the Problem.
    I'm using telerik, V.2011.1.519.40

    Thanks Advance,
    Mohamed
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017