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

Insert and Update without using insert tick mark?

3 Answers 121 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Venkatesh
Top achievements
Rank 1
Venkatesh asked on 15 Jan 2013, 06:54 AM
Hi,
Is it possible to use the radgrid insert,edit options without using the tick mark..

when the user clicks on "Add new item" a new row is shown( editmode is inplace). after inputting data, i dont want the user to click on tick mark(insert) . Is it possible to avoid using the tick mark and still do the insert and update.

If yes, please provide a sample code for the same.

Thanks

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 15 Jan 2013, 08:59 AM
Hi,

One suggestion is to insert/Update value in database on the TextChanged event in the insert/edit form. Please take a look into the following code snippet I tried.

C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridEditFormInsertItem)
    {
        GridEditFormInsertItem insertitem = (GridEditFormInsertItem)e.Item;
        TextBox txt = (TextBox)insertitem["UniqueName"].Controls[0];
        txt.AutoPostBack = true;
        txt.TextChanged += new EventHandler(txt_TextChanged);
    }
}
void txt_TextChanged(object sender, EventArgs e)
{
    TextBox txt = (TextBox)sender;
    GridEditFormInsertItem item = (GridEditFormInsertItem)txt.NamingContainer;
    string CustomerID = (item["UniqueName"].Controls[0] as TextBox).Text;
    //code for insertion
 
}

Thanks,
Shinu.
0
Venkatesh
Top achievements
Rank 1
answered on 15 Jan 2013, 09:58 AM
Hi,
Thanks for the reply.
How should the grid UI be? Is the ItemTemplate only enough?
0
Shinu
Top achievements
Rank 2
answered on 16 Jan 2013, 04:32 AM
Hi,

You can either use a TemplateColumn or a BoundColumn which will be rendered as textbox in edit mode. Here is the sample code.
aspx:
<telerik:RadGrid ID="RadGrid2" AutoGenerateColumns="false" runat="server" DataSourceID="SqlDataSource2">
 <MasterTableView>
   <Columns>
     <telerik:GridTemplateColumn>
        <EditItemTemplate>
            <asp:TextBox ID="TextBox2" AutoPostBack="true" runat="server" ontextchanged="TextBox2_TextChanged"></asp:TextBox>
        </EditItemTemplate>
     </telerik:GridTemplateColumn>
    <telerik:GridBoundColumn DataField="ShippedDate" UniqueName="ShippedDate"></telerik:GridBoundColumn>
   </Columns>
 </MasterTableView>
</telerik:RadGrid>

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