Enable False One Radtoolbarbutton

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

    Posted 13 Jul 2011 Link to this post

    Inside The Radgrid
    I have three RadToolBarButton button .
    I want enable false one RadToolBarButton button
    how to find control radgrid inside RadToolBarButton

    Thanks,
    Mohamed.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 13 Jul 2011 Link to this post

    Hello Mohamed,

    Try the following code snippet in ItemDataBound event  to access RadToolBarButton.

    aspx:
    <telerik:GridTemplateColumn>
      <ItemTemplate>
         <telerik:RadToolBar ID="RadToolBar1" runat="server">
              <Items>
                 <telerik:RadToolBarButton runat="server" Text="Button 1">
                 </telerik:RadToolBarButton>     
              </Items>
         </telerik:RadToolBar>
      </ItemTemplate>
    </telerik:GridTemplateColumn>

    C#:
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
           if (e.Item is GridDataItem)
            {
                GridDataItem item = (GridDataItem)e.Item;
                RadToolBar tool = (RadToolBar)item.FindControl("RadToolBar1");
                RadToolBarItem toolitem= tool.FindItemByText("Button 1");
                toolitem.Enabled = false;
            }
    }

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

    Posted 13 Jul 2011 Link to this post

    Thanks for reply princy ,
    object reference error come
    i bind radtoolbar like that code

    <telerik:RadGrid ID="RadgridKbaseList" runat="server" AllowPaging="true" AllowSorting="true"
                        AllowAutomaticInserts="True" AllowAutomaticUpdates="True" GridLines="None" AutoCompleteType="Disabled"
                        OnNeedDataSource="RadgridKbaseList_NeedDataSource" Skin="Office2007" OnItemDataBound="RadgridKbaseList_ItemDataBound"
                        OnItemCommand="RadgridKbaseList_ItemCommand" PageSize="5" AllowFilteringByColumn="True"
                        OnPreRender="RadgridKbaseList_PreRender">
                        <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top" EditMode="PopUp"
                            DataKeyNames="Articleid" IsFilterItemExpanded="false" AllowFilteringByColumn="true">
                            <CommandItemTemplate>
                                <telerik:RadToolBar ID="KbaseListToolbar" runat="server" Style="margin-top: 6px;"
                                    Width="100%" OnClientButtonClicking="onToolBarClientButtonClicking">
                                    <Items>
                                        <telerik:RadToolBarButton CommandName="InitInsert" ImageUrl="../../Content/images/AddRecord.gif"
                                            Text="Add new" onclick="openWin();">
                                        </telerik:RadToolBarButton>
                                        <telerik:RadToolBarButton Text="Filter" CommandName="Filter" ImageUrl="../../images/Filter 3.gif">
                                        </telerik:RadToolBarButton>
                                        <telerik:RadToolBarButton CommandName="RebindGrid" ImageUrl="../../Content/images/RefreshSelectedRecord.gif"
                                            Text="Refresh">
                                        </telerik:RadToolBarButton>


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

    Posted 14 Jul 2011 Link to this post

    Problem Resolved

    protected void RadgridKbaseList_ItemDataBound(object sender, GridItemEventArgs e)
            {
    if (e.Item is GridDataItem)
                   {
                       GridCommandItem commandItem = RadgridKbaseList.MasterTableView.GetItems(GridItemType.CommandItem)[0] as GridCommandItem;
                       RadToolBar toolBar = commandItem.FindControl("KbaseListToolbar") as RadToolBar;
                       RadToolBarItem toolitem = toolBar.FindItemByText("Add new");
                       toolitem.visible= false;
     }              }


    Thanks,
    Mohamed
Back to Top