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

old value during GridEditableItem on update

1 Answer 185 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Swapnil
Top achievements
Rank 1
Swapnil asked on 03 Sep 2014, 05:05 AM
Hi,
this is my code and i want old value along with new value to update record,i am done with new value but not getting idea @ old value

<telerik:RadGrid ID="RadGridTaskActivity" runat="server"
    OnNeedDataSource="RadGridTaskActivity_NeedDataSource"     onupdatecommand="RadGridTaskActivity_UpdateCommand" >
    <MasterTableView EditMode="EditForms" AutoGenerateColumns="true"
        CommandItemDisplay="Top" CommandItemSettings-ShowAddNewRecordButton="true" >
        <EditFormSettings FormMainTableStyle-HorizontalAlign="Center" EditColumn-ButtonType="PushButton"             InsertCaption="Add New Activity" >
            <FormStyle Width="100%" BackColor="LightCyan"></FormStyle>
        </EditFormSettings>
        <Columns>
            <telerik:GridEditCommandColumn HeaderStyle-Width="80px" ButtonType="ImageButton" UniqueName="EditColumn" HeaderText="Edit">
            </telerik:GridEditCommandColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

protected void RadGridTaskActivity_UpdateCommand(object sender, GridCommandEventArgs e)
       {
           GridEditableItem EditItem = e.Item as GridEditableItem;
           RadTextBox txtTestName = (RadTextBox)EditItem["ActiVityName"].FindControl("txtTestName");
           Hashtable newValues = new Hashtable();
           e.Item.OwnerTableView.ExtractValuesFromItem(newValues, EditItem);
           string NewActivityName = newValues["ActivityName"].ToString();
          //I WANT OLD ACTIVITY NAME ALSO WHICH I CAN SEE IN "GridEditableItem"
       }

Thanks.

1 Answer, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 05 Sep 2014, 03:28 PM
Hello Swapnil,

In order to extract the old activity name you can try modifying the code like demonstrated below.

C#:
protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e)
    {
        GridEditableItem EditItem = e.Item as GridEditableItem;
        ....
        string OldActivityName = EditItem.OwnerTableView.Items[EditItem.ItemIndex]["ActivityName"].Text;
    }

Additionally I recommend examining this help article in which you can find helpful information on how to access the cells and rows in RadGrid.

Regards,
Angel Petrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Swapnil
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Share this question
or