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

Multiple Edit Buttons on one grid

1 Answer 112 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kerry
Top achievements
Rank 1
Kerry asked on 13 Nov 2008, 07:03 AM
Hello, I have a two part question...I have a radGrid with an Edit LinkButton, this places the Grid into editting in-place...which is the desired effect.  However I have a need to have a second Edit button (Push Button).
1. Can I have another Edit Button that also places the Grid into Edit mode via Popup.

2. While is popup edit mode can I place additional fields on the popup that are not one of the Grid Columns. Essentially I'd like to turn the popup into a Dialog box,  the popup will capture some user input then when they click 'Update' I perform some operations using the data they inputted, Alternatively they can press cancel which would take them out of Edit mode.

Thank you

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 14 Nov 2008, 01:47 PM
Hello Kerry,

You can switch between the EditModes using two buttons taking advantage of their CommandName property. Check out the code below to understand better.
aspx:
 
<telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" runat="server" OnItemCommand="RadGrid1_ItemCommand" >         
   <MasterTableView DataKeyNames="FirstName" DataSourceID="SqlDataSource1" Width="1110px" CommandItemDisplay="Top"  >  
       <Columns>  
        <telerik:GridTemplateColumn UniqueName="TemplateColumn1">  
       <ItemTemplate>  
           <asp:LinkButton ID="LinkButton1" CommandName="InPlaceEdit" Text="InPlaceEdit" runat="server"></asp:LinkButton>
       </ItemTemplate>  
       </telerik:GridTemplateColumn>  
         
       <telerik:GridTemplateColumn UniqueName="TemplateColumn2">  
       <ItemTemplate>  
           <asp:Button ID="Button3" runat="server" Text="FormEdit" CommandName="FormEdit" />  
       </ItemTemplate>  
       </telerik:GridTemplateColumn>  
 
       </Columns>  
       <EditFormSettings>  
         <FormTemplate>  
              <asp:TextBox ID="TextBox2" Text='<%#Eval("ColumnName") %>' runat="server"></asp:TextBox>  
          </FormTemplate>  
       </EditFormSettings>  
  </MasterTableView>  
</telerik:RadGrid>  
         
 

cs:
 protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == "InPlaceEdit") 
        { 
            GridEditableItem editItem = (GridEditableItem)e.Item; 
            editItem.Edit = true
            RadGrid1.MasterTableView.EditMode = GridEditMode.InPlace; 
        } 
 
        if (e.CommandName == "FormEdit") 
        { 
            GridEditableItem editItem = (GridEditableItem)e.Item; 
            editItem.Edit = true
            RadGrid1.MasterTableView.EditMode = GridEditMode.PopUp; 
            RadGrid1.MasterTableView.EditFormSettings.EditFormType = GridEditFormType.Template;  
             
            
        } 
        RadGrid1.Rebind();  
   } 

Also you may find this link helpful which explains how to mimic autogenerated Edit Forms using Form Template.

Thanks
Princy.
Tags
Grid
Asked by
Kerry
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or