This is a migrated thread and some comments may be shown as answers.
Enable False One Radtoolbarbutton
3 Answers 69 Views
This is a migrated thread and some comments may be shown as answers.
mohamed
Top achievements
Rank 1
mohamed asked on 13 Jul 2011, 07:38 AM
Inside The Radgrid
I have three RadToolBarButton button .
I want enable false one RadToolBarButton button
how to find control radgrid inside RadToolBarButton

Thanks,
Mohamed.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 13 Jul 2011, 09:42 AM
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.
0
mohamed
Top achievements
Rank 1
answered on 13 Jul 2011, 12:13 PM
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.
0
mohamed
Top achievements
Rank 1
answered on 14 Jul 2011, 07:00 AM
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
Asked by
mohamed
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
mohamed
Top achievements
Rank 1
Share this question
or