New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

Retrieving Original Values for Edited Item

You can retrieve the old values for the edited item through the SavedOldValues property of the GridEditableItem(which is IDictionary collection of key -> value pairs). The keys in this collection are the UniqueNames of the editable columns and the values are the cell content for the edited row before the edit operation. The new values which the user entered before triggering the Update command can be fetched calling the ExtractValuesFromItem method.

Here is a sample code (note that this approach is applicable for auto-generated grid column editors):

ASP.NET
<telerik:RadGrid RenderMode="Lightweight" ID="RadGrid1" DataSourceID="SqlDataSource1" AllowSorting="True"
  runat="server" OnItemCommand="RadGrid1_ItemCommand" AutoGenerateColumns="true">
  <MasterTableView DataSourceID="SqlDataSource1">
    <Columns>
      <telerik:GridEditCommandColumn UniqueName="EditCommandColumn">
      </telerik:GridEditCommandColumn>
    </Columns>
  </MasterTableView>
</telerik:RadGrid>
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
    SelectCommand="SELECT TOP 10 [ContactName], [ContactTitle], [Address], [CustomerID] FROM [Customers]">
</asp:SqlDataSource>

If you have GridTemplateColumn inside the grid and want to obtain its original values on update command, you will need to store the old value on ItemDataBound when the grid item is in edit mode and then reference it on update. The code snippet below uses a Session variable for this purpose:

ASP.NET
<telerik:RadGrid RenderMode="Lightweight" ID="RadGrid1" DataSourceID="SqlDataSource1" Skin="WinXP" runat="server"
  Width="150px">
  <MasterTableView AutoGenerateColumns="false">
    <Columns>
      <telerik:GridTemplateColumn UniqueName="TemplateColumn" HeaderText="City">
        <ItemTemplate>
          <%# Eval("City") %>
        </ItemTemplate>
        <EditItemTemplate>
          <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("City") %>' />
        </EditItemTemplate>
      </telerik:GridTemplateColumn>
      <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" />
    </Columns>
  </MasterTableView>
</telerik:RadGrid>
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
    SelectCommand="SELECT [City] FROM [Customers]">
</asp:SqlDataSource>
Not finding the help you need?
Contact Support