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

insert form in grid

4 Answers 37 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Duy
Top achievements
Rank 1
Duy asked on 17 Jun 2013, 10:08 PM
i have a grid that i can trigger the edit form through grideditcommandcolumn. how do i add another column and make it insert and trigger the insert form as well. thank you for your help. i tried the below code but it didn't work. thank for your help

<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" PageSize="20"
                    AllowPaging="true" MasterTableView-HierarchyLoadMode="ServerBind" >
                    <PagerStyle Mode="NumericPages" />
<Columns>
                            <telerik:GridBoundColumn SortExpression="Amount" HeaderText="Amount" HeaderButtonType="TextButton" DataField="Amount" />
                            <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" ButtonType="LinkButton" EditText="Edit" />
                             <telerik:GridEditCommandColumn UniqueName="InsertCommandColumn" ButtonType="LinkButton" EditText="Insert" />
                        </Columns>
                        <EditFormSettings EditFormType="Template">
                            <FormTemplate>
                                     <telerik:RadTextBox ID="txt_Amount_Edit" runat="server" Width="120px"
                                                Value='<%#Eval("Amount")%>' />
                           </FormTemplate>
                        </EditFormSettings>
</telerik:RadGrid>

4 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 18 Jun 2013, 05:54 AM
Hello,


<FormTemplate>
                                     <telerik:RadTextBox ID="txt_Amount_Edit" runat="server" Width="120px"
                                                Value='<%#Eval("Amount")%>' />
 <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                    runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
                                </asp:Button
                                <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                    CommandName="Cancel"></asp:Button>
 
                           </FormTemplate>

OR

<telerik:GridTemplateColumn>
                      <ItemTemplate>
                          <asp:Button ID="btnEdit" runat="server" CommandName="Edit" Text="Edit" />
                          <asp:Button ID="btnSave" runat="server" CommandName="Update" Text="Update" Visible="false" />
                          <asp:Button ID="btnCancel" runat="server" CommandName="Cancel" Text="Cancel" Visible="false" />
                      </ItemTemplate>
                  </telerik:GridTemplateColumn>
protected void RadGrid1_PreRender(object sender, EventArgs e)
   {
       foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
       {
           if (item.Edit)
           {
               item.FindControl("btnEdit").Visible = false;
               item.FindControl("btnSave").Visible = true;
               item.FindControl("btnCancel").Visible = true;
           }
           else
           {
               item.FindControl("btnEdit").Visible = true;
               item.FindControl("btnSave").Visible = false;
               item.FindControl("btnCancel").Visible = false;
           }
       }
   }


Thanks,
Jayesh Goyani
0
Duy
Top achievements
Rank 1
answered on 18 Jun 2013, 02:03 PM
GridEditFormInsertItem
 can't seem to be found it kept asking me to create a method in the backend.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 19 Jun 2013, 08:50 AM
Hello,

We can not add more then one "GridEditCommandColumn " column in to Grid.

Can you please elaborate your scenario ?

Thanks,
Jayesh Goyani
0
Duy
Top achievements
Rank 1
answered on 19 Jun 2013, 01:26 PM
i found the problem. you gave me the code in c#. i was using vb so i had to ad typeof infront container. it's working now. thanks
Tags
Grid
Asked by
Duy
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Duy
Top achievements
Rank 1
Share this question
or