This is a migrated thread and some comments may be shown as answers.

Disable ImageButton on Hierarchical Grid

1 Answer 49 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Amol
Top achievements
Rank 2
Amol asked on 30 Jun 2009, 02:55 PM
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

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 01 Jul 2009, 04:58 AM
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
Tags
Grid
Asked by
Amol
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Share this question
or