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

[Solved] Grid Expand + Buttons

1 Answer 103 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris Heywood
Top achievements
Rank 1
Chris Heywood asked on 20 Nov 2009, 12:28 PM
Hi

I'm pretty new to RadGrid so take it easy on me please.

I'd like to use the expand functionality to show buttons on the expanded line rather than any hierarchical data sourced from the expanded line, is it possible to just have a single line with a number of buttons appear when the expand is clicked?  Obviously I'd need to catch the click event of these buttons also.

Thanks in advance.

Chris.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 23 Nov 2009, 08:57 AM
Hello Chris,

You can use the NestedViewTemplate of the Grid to nest any controls in the grid which will be displayed on expanding each row. You can place buttons in the NestedViewTemplate and set its CommandNames which will trigger the ItemCommand event of the grid when the corresponding button is clicked. Here's an example:
aspx:
<telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1"  AutoGenerateColumns="true" runat="server" OnItemCommand="RadGrid1_ItemCommand"
        <MasterTableView DataSourceID="SqlDataSource1"
               <NestedViewTemplate> 
                    <asp:Button ID="Button1" runat="server" Text="CommandButton1" CommandName="Command1" /> 
                    <asp:Button ID="Button2" runat="server" Text="CommandButton2" CommandName="Command2"/> 
                    <asp:Button ID="Button3" runat="server" Text="CommandButton3" CommandName="Command3"/>                     
              </NestedViewTemplate>    
                  .... 

c#:
  protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == "Command1"
        { 
 
        } 
    } 

Thanks
Shinu.
Tags
Grid
Asked by
Chris Heywood
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or