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

Can't get changed value in UpdateCommand

2 Answers 163 Views
Grid
This is a migrated thread and some comments may be shown as answers.
GrZeCh
Top achievements
Rank 2
GrZeCh asked on 25 Apr 2008, 01:42 PM
Hello!

Whatever I do I just can't get changed values from fields which I'm editing.

Column in RadGrid:

<telerik:GridCheckBoxColumn HeaderText="Truck" DataField="Truck_" DataType="System.Boolean"
</telerik:GridCheckBoxColumn> 

Codebehind (taken from here: http://www.telerik.com/help/radcontrols/prometheus/grdInsertUpdateDeleteAtDatabaseLevel.html):

GridEditableItem editedItem = e.Item as GridEditableItem; 
bool TruckCheckBox = ((CheckBox)editedItem["Truck_"].Controls[0]).Checked;   

Thanks in advance

2 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 29 Apr 2008, 08:27 AM
Hello GrZeCh,

You can get the elements from the editForm, by getting a reference to the field, the control in it, and then casting it to the desired destination control:

.cs
 protected void RadGrid1_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)     
   {     
       //Get the GridEditableItem of the RadGrid       
       GridEditableItem eeditedItem = e.Item as GridEditableItem;     
       //Get the primary key value using the DataKeyValue.       
       string EmployeeID = editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["EmployeeID"].ToString();     
       //Access the textbox from the edit form template and store the values in string variables.       
       string LastName = (editedItem["LastName"].Controls[0] as TextBox).Text;     
       string FirstName = (editedItem["FirstName"].Controls[0] as TextBox).Text;     
       string Title = (editedItem["Title"].Controls[0] as TextBox).Text;     
       string Address = (editedItem["Address"].Controls[0] as TextBox).Text;     
       string City = (editedItem["City"].Controls[0] as TextBox).Text;     
 

The same is applicable for a checkbox control.
Give this suggestion a try and if the issue persits, you can open a formal support ticket, and send us the problematic application.

Regards,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Peter
Top achievements
Rank 1
answered on 22 Oct 2014, 05:37 AM
Thanks - mine was:

GridEditableItem editItem = e.Item as GridEditableItem;
_isIgnore = ((CheckBox)((GridEditableItem)e.Item)["chkIgnore"].Controls[0]).Checked;
Tags
Grid
Asked by
GrZeCh
Top achievements
Rank 2
Answers by
Yavor
Telerik team
Peter
Top achievements
Rank 1
Share this question
or