RadToolBar button visibility inside Grid/Mastertable/Toolbar

4 posts, 0 answers
  1. Divya
    Divya avatar
    12 posts
    Member since:
    Mar 2016

    Posted 15 May Link to this post

    I have following code structute

     

    <telerik:RadGrid    ID="xx">
        <MasterTableView CommandItemDisplay="Top" DataKeyNames="Key">
            <RowIndicatorColumn>
                <HeaderStyle Width="20px"></HeaderStyle>
            </RowIndicatorColumn>
            <CommandItemTemplate>
                <telerik:RadToolBar ID="yy" runat="server" AutoPostBack="true" Width="100%">
                    <Items>
                        <telerik:RadToolBarButton  CommandName="InitInsert" ResourceName="Add" ImageUrl="~/App_Themes/Default/Add.gif" Text="Add" ></telerik:RadToolBarButton>
                    </Items>
                </telerik:RadToolBar> ....................Cont....

     

    How can I hide RadToolBarButton  using C# code ? how can I access this toolbar button if its inside Grid/MasterTable/Toolbar hirarchi

     

  2. Divya
    Divya avatar
    12 posts
    Member since:
    Mar 2016

    Posted 16 May in reply to Divya Link to this post

    Can anybody help me on this ?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Divya
    Divya avatar
    12 posts
    Member since:
    Mar 2016

    Posted 16 May in reply to Divya Link to this post

    I want to do this In a Private method ...

    public void LoadData()
            {
              .............................................
                if (Data.Count == 1)
                {
                    AddFlag = false;

    I can access following but not inner items
     RadGrid grid = (RadGrid )this.FindControl("xx"); 

     tried this but no luck
                    //Radtoolbar = (Radtoolbar )this.FindControl("yy");
                   // ((RadtoolbarButton)toolbar.FindButtonByCommandName("InitInsert")).Visible = false;


                }
            }

     

  5. Ivan Danchev
    Admin
    Ivan Danchev avatar
    829 posts

    Posted 18 May Link to this post

    Hello Divya,

    An approach you can use to set the ToolBar to visible or invisible is to set its CssClass property. So when you want to make it invisible you can set the following custom class:
    toolbar.CssClass = "toolBarInvisible";

    and when you want to make it visible again the following one:
    toolbar.CssClass = "toolBarVisible";

    You will have to add the corresponding CSS rules which will set the visibility depending on the ToolBar's currently set custom class:
    .toolBarInvisible {
        visibility: hidden;
    }
     
    .toolBarVisible{
        visibility: visible;
    }

    For accessing the ToolBar you can see this forum thread, where it is shown how to access a control placed in a Grid's CommandItemTemplate.

    Regards,
    Ivan Danchev
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top