Hi,
I am using telerik radgrid with EditMode="InPlace".Grid is bound to list of transaction objects as shown below in server side code section. I have a GridDropDownColumn which shows local currency for transactions. When I click on "edit" button which is generated as GridEditCommandColumn, I get the row in edit mode and list of currencies in the dropdown (GridDropDownColumn). But when grid is in edit mode, I need to set the previous/old value in the dropdownlist and I am unable to do that. What I need to know is how to find out old values when grid is in edit mode so that I can set selectedvlaue in dropdownlist. Is there any Server Side API which can help me out?
Following is the declaration of radgrid on aspx page.
//Design time code
<telerik:RadGrid ID="rgGLAdjustments" runat="server" AllowExportToExcel="true"
Width="100%" OnDeleteCommand="rgGLAdjustments_DeleteCommand" OnNeedDataSource="rgGLAdjustments_NeedDataSource"
OnItemDataBound="rgGLAdjustments_ItemDataBound" OnEditCommand="rgGLAdjustments_EditCommand">
<MasterTableView DataKeyNames="TransactionID" EditMode="InPlace">
<Columns>
<%--Some GridBoundColumns are here--%>
<telerik:GridDropDownColumn UniqueName="LocalCurrency" HeaderText="Local Currency"
DropDownControlType="DropDownList" DataField="LocalCurrency" ListDataMember="GetDataTable"
ListValueField="LocalCurrency" ListTextField="LocalCurrency">
</telerik:GridDropDownColumn>
<telerik:GridEditCommandColumn UpdateText="Update" UniqueName="EditCommandColumn"
CancelText="Cancel" EditText="Edit">
</Columns>
</MasterTableView>
</telerik:RadGrid>
"GetDataTable" is the property on my aspx.cs which returns a datatable and I bind that datatable to dropdowlist in "rgGLAdjustments_ItemDataBound" event handler as shown below
//Server side code
protected void rgGLAdjustments_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
if (e.Item is GridEditableItem && (e.Item as GridEditableItem).IsInEditMode)
{
GridEditableItem editedItem = e.Item as GridEditableItem;
GridEditManager editMan = editedItem.EditManager;
GridDropDownListColumnEditor editor = editMan.GetColumnEditor("LocalCurrency") as GridDropDownListColumnEditor;
//Tried following but it is always null
//editedItem.SavedOldValues
editor.DataSource = this.GetDataTable;
editor.DataValueField = "LocalCurrency";
editor.DataTextField = "LocalCurrencyValue";
editor.DataBind();
}
}
protected void rgGLAdjustments_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
this.rgGLAdjustments.DataSource = this.TransactionObjectsCollection;
}
Grid is bound to List of transaction objects in "OnNeedDataSource" handler as shown above.
I tried "editedItem.SavedOldValues" in the above server side code but it is always null. I also tried it in "OnEditCommand" handler but same result. Please advice.
Thanks