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

Not Able to get updated value from Rad Grid

5 Answers 203 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mainak
Top achievements
Rank 1
mainak asked on 10 Sep 2010, 09:05 AM
i am  facing some problem to get the updated value.
Like , i have rad grid and editing this grid with Popup option.
the edit popup is coming. But in the updated event i am still getting the old value , not the updated one.
 
The code as belows... 
 
.... ASPX page code

</

 

telerik:RadCodeBlock>

 

 

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">

 

 

<telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None"

 

 

AllowPaging="True" PageSize="20" AllowSorting="True" AutoGenerateColumns="False"

 

 

ShowStatusBar="true" AllowAutomaticDeletes="True" AllowAutomaticInserts="True"

 

 

AllowAutomaticUpdates="True" HorizontalAlign="NotSet" AllowMultiRowEdit="False" OnUpdateCommand="RadGrid1_ItemUpdated"

 

 

OnItemCommand="RadGrid1_ItemCommand"

 

>

 

 

 

<MasterTableView CommandItemDisplay="TopAndBottom" DataKeyNames="ActionID" EditMode="PopUp">

 

 

<Columns>

 

 

<telerik:GridEditCommandColumn>

 

 

</telerik:GridEditCommandColumn>

 

 

<telerik:GridBoundColumn UniqueName="Action_Type_Name" HeaderText="Action" DataField="Action_Type_Name">

 

 

</telerik:GridBoundColumn>

 

 

 

<telerik:GridBoundColumn UniqueName="ValidFrom" HeaderText="ValidFrom" DataField="ValidFrom">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn UniqueName="ValidTo" HeaderText="ValidTo" DataField="ValidTo">

 

 

</telerik:GridBoundColumn>

 

 

 

</Columns>

 

 

 

<EditFormSettings InsertCaption="Add new item" EditFormType="Template">

 

 

<FormTemplate>

 

 

<table id="Table1" cellspacing="1" cellpadding="1" width="250" border="0">

 

 

<tr>

 

 

<td>

 

 

</td>

 

 

<td>

 

 

</td>

 

 

</tr>

 

 

<tr>

 

 

<td>

 

Action:

 

</td>

 

 

<td>

 

 

<asp:TextBox ID="TextBoxAction" Text='<%# Bind( "Action_Type_Name") %>' runat="server">

 

 

</asp:TextBox>

 

 

</td>

 

 

</tr>

 

 

<tr>

 

 

<td>

 

Valid From:

 

</td>

 

 

<td>

 

 

<asp:TextBox ID="TextBoxValidForm" Text='<%# Bind( "ValidFrom") %>' runat="server">

 

 

</asp:TextBox>

 

 

</td>

 

 

</tr>

 

 

<tr>

 

 

<td>

 

Valid To:

 

</td>

 

 

<td>

 

 

<asp:TextBox ID="TextBoxValidTo" Text='<%# Bind( "ValidTo") %>' runat="server">

 

 

</asp:TextBox>

 

 

</td>

 

 

</tr>

 

 

 

</table>

 

 

 

<table style="width: 100%">

 

 

<tr>

 

 

<td align="right" colspan="2">

 

 

<asp:Button ID="Button1" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'

 

 

runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>

 

 

</asp:Button>&nbsp;

 

 

<asp:Button ID="Button2" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel">

 

 

</asp:Button>

 

 

</td>

 

 

</tr>

 

 

</table>

 

 

</FormTemplate>

 

 

</EditFormSettings>

 

 

</MasterTableView>

 

 

<ClientSettings>

 

 

<ClientEvents OnRowDblClick="RowDblClick" />

 

 

</ClientSettings>

 

 

</telerik:RadGrid>

 

 

CS file code....

 

 

 

 

 

 

 

protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)

 

{

 

if (e.CommandName == RadGrid.UpdateCommandName)

 

{

 

//GridEditFormItem editItem = (GridEditFormItem)(e.Item as GridDataItem).EditFormItem;

 

 

//TextBox txtFirstName = (TextBox)editItem.FindControl("TextBoxAction"); //access TextBox

 

 

 

GridEditableItem editedItem = e.Item as GridEditableItem;

 

 

string abc = (editedItem.FindControl("TextBoxAction") as TextBox).Text;  ---- but , if i change the action value ...  still i am

 

}

}

 

 

 

Thanks ....

 

 

 

Regards
Mainak

5 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 10 Sep 2010, 09:25 AM
Hello Mainak,

The grid's EditItems collection contains the items (rows) of the grid that are currently being edited. When using EditForms or PopUp however, the items in the collection are the items in their initial (unedited) form. To access the edit form for an item in the list, use its EditFormItem property.

Please refer to this help topic for more information how to achieve the desired by you functionality.

Kind regards,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
mainak
Top achievements
Rank 1
answered on 10 Sep 2010, 01:12 PM
Hi,

I have try with the following code ... but still not getting ... any problem in HTML .._
Please help me ...

 

foreach (GridDataItem item in RadGrid1.EditItems)

 

{

 

GridEditableItem itemToEdit =

 

(item.OwnerTableView.EditMode ==

GridEditMode.PopUp)

 

? item : (

GridEditableItem)item.EditFormItem;

 

 

TextBox txtFirstName = (TextBox)itemToEdit.FindControl("TextBoxAction");

 

}



Regards
Mainak
0
Pavlina
Telerik team
answered on 10 Sep 2010, 02:29 PM
Hello Mainak,

The new values which the user entered before triggering the Update command can be fetched calling the ExtractValuesFromItem method. You can review the help topic below which elaborates on how to retrieve the old / new values for the edited item:
http://www.telerik.com/help/aspnet/grid/grdretrieveoriginalvaluesforediteditem.html

Regards,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
mainak
Top achievements
Rank 1
answered on 10 Sep 2010, 02:47 PM
Hi,

This code also , i have tried as follows..

  Hashtable newValues = new Hashtable();
               e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);


But for me newValues is coming as null object.

Please send me if you have any sample code to get only the updated value in popup item. same as my pasted code.
I dont want any Database related update, only how to get updated value.
If possible , please review my code and send me as zip file.
Please...

Thanks ..
Regards
Mainak
0
Pavlina
Telerik team
answered on 13 Sep 2010, 11:40 AM
Hello Mainak,

Attached to this message is a sample project that is working as expected. Please give it a try and let me know if it works for you. 

I hope this helps.

All the best,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
mainak
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
mainak
Top achievements
Rank 1
Share this question
or