Disable ImageButton on Hierarchical Grid

2 posts, 0 answers
  1. Amol
    Amol avatar
    57 posts
    Member since:
    Apr 2008

    Posted 30 Jun 2009 Link to this post

    Hello Friends,

    I have a Hierarchical Rad grid which contains 4 level of Hierarchy.

    On the 2nd, 3rd and 4th Hierarchy of grid, there is a template column which contains one imagebutton.

    My requirement is to hide the imagebutton on the last row of  each hierarchical grid.

    I had tried on Page_Pre-render event using

                  ImageButton downButtonPosition = (ImageButton)radgrid.MasterTableView.DetailTables[0].Items[radgrid.MasterTableView.DetailTables[0].Items.Count - 1].FindControl("ibtnDown");

    Now to retrieve last row of DetailTable of Radgrid and On Which event i can get it?

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

    Posted 30 Jun 2009 Link to this post

    Hi Amol,

    You may try the following code snippet If you are having the ImageButton with the same ID specified in each inner level of the Grid.

    ASPX:
     
         <MasterTableView CommandItemDisplay="Top" EditMode="EditForms" Name="Master" ShowGroupFooter="true" GroupLoadMode="Client" AllowAutomaticUpdates="True"  ShowFooter="True" DataSourceID="SqlDataSource1" DataKeyNames="ProductID" CellSpacing="-1"  > 
                
              <Columns> 
                  ....... 
              </Columns> 
                  
                 <DetailTables> 
                          <telerik:GridTableView runat="server"  Caption="Detail"  DataSourceID="SqlDataSource1"  Name="Detail" CellSpacing="-1" > 
                             <Columns> 
                               <telerik:GridTemplateColumn UniqueName="TempCol" HeaderText="TempCol" > 
                                <ItemTemplate> 
                                    <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Images/dot.gif" /> 
                                </ItemTemplate> 
                               </telerik:GridTemplateColumn> 
                             </Columns> 
                            <DetailTables> 
                               <telerik:GridTableView runat="server" Name="Detail" DataSourceID="SqlDataSource1" >  
                                 <Columns> 
                                    <telerik:GridTemplateColumn UniqueName="TempCol" HeaderText="TempCol" > 
                                      <ItemTemplate> 
                                        <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Images/dot.gif" /> 
                                      </ItemTemplate> 
                               </telerik:GridTemplateColumn> 
                                 </Columns> 
                               </telerik:GridTableView> 
                              </DetailTables> 
                          </telerik:GridTableView> 
                    </DetailTables> 
                  
                </MasterTableView> 

    CS:
     
     protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
        { 
           if((e.Item is GridDataItem)&&(e.Item.OwnerTableView.Name!="Master")&&(e.Item.ItemIndex==RadGrid1.MasterTableView.Items.Count-1)) 
            { 
                GridDataItem item = (GridDataItem)e.Item; 
                ImageButton imgbtn = (ImageButton)item.FindControl("ImageButton1"); 
                imgbtn.Visible = false
            } 
          
        } 


    Note: Set the Name property for each level.

    Thanks
    Shinu
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top