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

[Solved] Add capability of RadGrid

4 Answers 93 Views
Grid
This is a migrated thread and some comments may be shown as answers.
DC
Top achievements
Rank 1
DC asked on 23 Nov 2009, 06:39 AM
Hi,
I have a rad grid with only Add and Delete functionality. Please note that there is no "EDIT" button on the records.
when I click on "Add" the new row for adding a new record shows up but when the grid is in Add mode, I dont see "insert" and "cancel" buttons on the new row. This thing does not happen when I have "Edit" button on the grid. Please advice as to how can I have "insert" and "cancel" buttons on the new row when there is no edit button on the grid.

Thanks
DC

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 23 Nov 2009, 07:28 AM
Hello,

One suggestion would be using FormTemplate for showing custom insert form with buttons for insert and cancel functions. See the example.

ASPX:
 
<MasterTableView AutoGenerateColumns="False" DataSourceID="SqlDataSource1" 
    DataKeyNames="CustomerID"
    <EditFormSettings EditFormType="Template" UserControlName="WebUserControl.ascx"
        <FormTemplate> 
            <table id="tab"
                <tr> 
                    <td> 
                        <telerik:RadComboBox ID="RadComboBox1" runat="server"
                            <Items> 
                                <telerik:RadComboBoxItem Text="Item1" /> 
                                <telerik:RadComboBoxItem Text="Item2" /> 
                            </Items> 
                        </telerik:RadComboBox> 
                    </td> 
                    <td> 
                        <asp:Button ID="Button1" runat="server" Text="Insert" CommandName="PerformInsert" /> 
                    </td> 
                    <td> 
                        <asp:Button ID="Button2" runat="server" Text="Cancel" CommandName="Cancel" /> 
                    </td> 
                </tr> 
            </table> 
        </FormTemplate> 
    </EditFormSettings> 
    <Columns> 
      . . . 
    </Columns> 
</MasterTableView> 

Checkout the demo for more information on FormTemplate.
Form Template Edit Form

-Shinu.
0
DC
Top achievements
Rank 1
answered on 24 Nov 2009, 06:53 AM
Hi Shinu,
Thanks for your reply.
My application is using radgrid with editmode = "InPlace". Hence I need soultion to my problem with editmode = "inplace".
Kindly suggest somthing else.

Looking forward to your reply soon.

Sincerely
DC
0
Accepted
Princy
Top achievements
Rank 2
answered on 24 Nov 2009, 09:09 AM
Hi DC,

When using Inplace editmode, you can have the EditCommandColumn displayed in the grid, inorder to show the insert and cancel buttons. Then you can hide the EditCommandColumn conditionally using the following code:
c#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
   { 
       if (e.Item is GridDataInsertItem && e.Item.OwnerTableView.IsItemInserted) 
        { 
            RadGrid1.MasterTableView.GetColumn("EditCommandColumnUniqueName").Visible = true
            foreach (GridDataItem dataItem in RadGrid1.MasterTableView.Items) 
            { 
                ((LinkButton)dataItem["EditCommandColumnUniqueName"].Controls[0]).Visible = false
            } 
        } 
        else 
        { 
            RadGrid1.MasterTableView.GetColumn("EditCommandColumnUniqueName").Visible = false
        } 
    } 

Thanks
Princy.
0
DC
Top achievements
Rank 1
answered on 25 Nov 2009, 08:50 AM
Thanks Princy, It worked
Tags
Grid
Asked by
DC
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
DC
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or