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

[Solved] Simple update and insert (manual binding)

2 Answers 100 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lars
Top achievements
Rank 1
Lars asked on 25 Aug 2009, 09:04 AM
Hi,

is there a simple way to get the old (and the new values) of GridBoundColumns inside the update/insert command?

I have bound my data manually to the grid. (By setting the DataSource to a DataTable)
Three fields are relevant. (UID, DCId, MRDR_NR). I only showup some of these in the Editmode.
<mastertableview editmode="EditForms"   
                         enableheadercontextmenu="True"   
                         insertitempageindexaction="ShowItemOnFirstPage"   
                         ShowGroupFooter="True" InsertItemDisplay="Bottom" 
                         DataKeyNames="UID" CommandItemDisplay="Bottom">  
            <Columns> 
                <telerik:GridBoundColumn   
                    DataField="UID" ReadOnly="True"   
                    HeaderText="UID" UniqueName="UID" Visible="false">  
                </telerik:GridBoundColumn>      
                <telerik:GridBoundColumn DataField="DCId"   
                        HeaderText="DCId" UniqueName="DCId">  
                    <ItemStyle Width="100" /> 
                </telerik:GridBoundColumn>              
                <telerik:GridBoundColumn DataField="MRDR_NR" HeaderText="MRDR_NR" UniqueName="MRDR_NR">  
                    <ItemStyle Width="100" /> 
                </telerik:GridBoundColumn> 
            </Columns>                                                          
</mastertableview>  

Now i just want to update a value in my DataTable. Like (update xy set MRDR_Nr=NEW where UID=OLD).
How can i get the OLD and NEW Values inside the UpdateCommand?
I found an example to find out the OLD Values of my data. But not the NEW Values. And not by FieldNames.

protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e)  
    {  
        GridEditableItem editedItem = e.Item as GridEditableItem;  
        GridEditManager editMan = editedItem.EditManager;  
        foreach (GridColumn column in e.Item.OwnerTableView.RenderColumns)  
        {  
            if (column is IGridEditableColumn)  
            {  
                IGridEditableColumn editableCol = (column as IGridEditableColumn);  
                if (editableCol.IsEditable)  
                {  
                    IGridColumnEditor editor = editMan.GetColumnEditor(editableCol);  
                    string editorText = "unknown";  
                    object editorValue = null;  
                    if (editor is GridTextColumnEditor)  
                    {  
                        editorText = (editor as GridTextColumnEditor).Text;  
                        editorValue = (editor as GridTextColumnEditor).Text;  
                    } 

Is there a way to get the data of my columns?
Like "item["DCId"].value" (old and new)?

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 25 Aug 2009, 09:55 AM
Hello Lars,

Check out the following help document which explians how to retrieve the old values and the new values for the edited item.
Probably this should help you out.
Retrieving original values for edited item

Thanks
Princy.
0
Lars
Top achievements
Rank 1
answered on 25 Aug 2009, 12:20 PM
obsolete!
Tags
Grid
Asked by
Lars
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Lars
Top achievements
Rank 1
Share this question
or