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

SavedOldValues on External Form

1 Answer 22 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mayuresh
Top achievements
Rank 1
Mayuresh asked on 21 Jul 2011, 09:47 PM
Can I use SavedOldValues() for a GridEditableDataItem if I am using External Form ? If not, how do I create a business object with the old values from Selected Grid Data Item that is up for Editing ?

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 11 Sep 2012, 09:49 AM
Hi,

I suppose you need the old values in the FormTemplate.You can save old value on ItemDataBound when the grid item is in edit mode and then reference it on update. Here is the sample code snippet I tried.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="false" AutoGenerateEditColumn="true" onitemdatabound="RadGrid1_ItemDataBound" onupdatecommand="RadGrid1_UpdateCommand">
    <MasterTableView>
        <EditFormSettings EditFormType="Template">
            <FormTemplate>
                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("OrderID") %>' ></asp:TextBox>
                <asp:Button ID="Upd" runat="server" CommandName="Update" Text="Update" />
            </FormTemplate>
        </EditFormSettings>
        <Columns>
            <telerik:GridBoundColumn UniqueName="OrderID" DataField="OrderID">
            </telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {
        TextBox txtBox = e.Item.FindControl("TextBox1") as TextBox;
        Session["savedOldValue"] = txtBox.Text;
    }
}
protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e)
{
    string val= (string)Session["savedOldValue"];
}

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