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

How do I get original values when updating grid

2 Answers 117 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 17 Feb 2009, 03:12 PM
I must not be smart enough to figure this out. I have tried every combination of things I can think of.

I am using a dataset to populate a grid (datasource = dataset). This grid has an edit button using forms which works fine. I can easily get the new values when form is updated, but I can't seem to figure out how to get the original value. 

I have tried the savedoldvalues property of the grideditableitem but no values exist. I have tried this in both the item command event and the updatecommand event.

I have tried to save the values in a session variable at the itemdatabound event but can't seem to get the values.

        <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" GridLines="None">  
            <MasterTableView CommandItemDisplay="TopAndBottom" AllowSorting="True">  
                <RowIndicatorColumn> 
                    <HeaderStyle Width="20px" /> 
                </RowIndicatorColumn> 
                <ExpandCollapseColumn> 
                    <HeaderStyle Width="20px" /> 
                </ExpandCollapseColumn> 
                <Columns> 
                    <telerik:GridDateTimeColumn DataField="DATE" DataFormatString="{0:yyyy-MM-dd}" HeaderText="Date" 
                        UniqueName="DATE">  
                    </telerik:GridDateTimeColumn> 
                    <telerik:GridBoundColumn DataField="REFNO" HeaderText="Ref #" UniqueName="REFNO">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="AMOUNT" HeaderText="Amount" UniqueName="AMOUNT">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="REIMBPER" HeaderText="Reimbursement%" UniqueName="REIMBPER">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="REIMBAMT" HeaderText="Reimbursement Amount" UniqueName="REIMBAMT">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridEditCommandColumn> 
                    </telerik:GridEditCommandColumn> 
                    <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="column1">  
                    </telerik:GridButtonColumn> 
                </Columns> 
                <EditFormSettings> 
                    <EditColumn UniqueName="EditCommandColumn1">  
                    </EditColumn> 
                </EditFormSettings> 
            </MasterTableView> 
            <FilterMenu EnableTheming="True">  
                <CollapseAnimation Duration="200" Type="OutQuint" /> 
            </FilterMenu> 
        </telerik:RadGrid> 
 

I have wasted such an incredible amount of time on this can someone help?

Steve

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 18 Feb 2009, 10:29 AM
Hi steve,

I guess you are trying to get the value of rows before updating it. If that the case, you can try below code snippets for getting the values. I have tried this code in UpdateCommand event.

CS:
protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e) 
    GridDataItem item = (GridDataItem) RadGrid1.Items[e.Item.ItemIndex]; // Get the original row 
    string amount = item["AMOUNT"].Text; // Value before updating 

Thanks,
Shinu.
0
Steve
Top achievements
Rank 1
answered on 18 Feb 2009, 01:08 PM
Great, thanks.

Now I am a bit smarter.
Tags
Grid
Asked by
Steve
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Steve
Top achievements
Rank 1
Share this question
or