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

in-line insert & update in radgrid

4 Answers 196 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Parodist
Top achievements
Rank 1
Parodist asked on 24 Mar 2009, 07:46 PM
I have the following codes to update which is working but I would like insert a new row which I need your inputs
                      
   protected void RgUserMast_UpdateCommand(object source, GridCommandEventArgs e)  
    {  
 
        if (e.CommandName == "Update")  
        {  
            GridEditableItem dataItem = (GridEditableItem)e.Item;  
            string ProcessId = dataItem.GetDataKeyValue("ProcessId").ToString();  
            GridEditableItem editedItem = e.Item as GridEditableItem;  
            GridEditManager editMan = editedItem.EditManager;  
            GridTextBoxColumnEditor editor = editMan.GetColumnEditor("ProcessName"as GridTextBoxColumnEditor;  
            string selectedValue = editor.Text;  
            Query = "Update ProcessMaster set ProcessName='" + editor.Text + "' where ProcessId='" + ProcessId + "'";  
            obj.ExecuteNonQuery(Query);  
         
        }   
                        <telerik:GridBoundColumn DataField="ProcessId" HeaderText="ProcessId" SortExpression="ProcessId" 
                        UniqueName="ProcessId" ReadOnly="true" Visible="true" HeaderStyle-Font-Bold="true" 
                        HeaderStyle-HorizontalAlign="Center">  
                        <HeaderStyle HorizontalAlign="Center" Font-Bold="True" Width="30px"></HeaderStyle> 
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn DataField="ProcessName" HeaderText="Process" SortExpression="ProcessName" 
                        UniqueName="ProcessName" ReadOnly="false" HeaderStyle-Font-Bold="true" HeaderStyle-HorizontalAlign="Center">  
                        <HeaderStyle HorizontalAlign="Center" Font-Bold="True" Width="30px"></HeaderStyle> 
                        </telerik:GridBoundColumn> 
                       
                        

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Mar 2009, 04:02 AM
Hi Parodist,

Refer the following help article which explains how to perform Insert/Update/Delete operation manually in code behind.
Insert/Update/Delete at database level with queries

Thanks
Shinu.

0
Parodist
Top achievements
Rank 1
answered on 25 Mar 2009, 08:53 AM
Thanks for the response Shinu,I get an error ' Unable to cast object of type 'Telerik.Web.UI.GridDataInsertItem' to type 'Telerik.Web.UI.GridEditFormInsertItem'. ' if I follow your instructions.Need your helping hand.


Thanks
0
Princy
Top achievements
Rank 2
answered on 25 Mar 2009, 09:11 AM
Hi Parodist,

GridEditFormInsertItem is used to access the items when the grid's edit mode is EditForms whereas GridDataInsertItem is used when the edit mode is InPlace. If you are use using In line editing then you can replace GridEditFormInsertItem with GridDataInsertItem as shown below:
cs:
 protected void RadGrid1_InsertCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)    
   {    
         
       GridDataInsertItem insertItem = (GridDataInsertItem)e.Item;    
         ..... 
 
   } 

Thanks
Princy.
0
Parodist
Top achievements
Rank 1
answered on 25 Mar 2009, 10:58 AM
Thanks again Princy.Love you all.
Tags
Grid
Asked by
Parodist
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Parodist
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or