I have a UserControl as custom edit form inside my grid. It's bound directly to a data item using the Data Item property as demonstrated here.
private object _dataItem = null;
public object DataItem
{
get {return this._dataItem;}
set {this._dataItem = value;}
}
Binding expressions display values in controls like this:
<
div
>
<
asp:TextBox
ID
=
"txtApples"
runat
=
"server"
Text='<%# Bind("Apples") %>' Width="50px" Enabled="false" ></
asp:TextBox
>
<
asp:TextBox
ID
=
"txtOranges"
runat
=
"server"
Text='<%# Bind("Oranges") %>' Width="50px" ></
asp:TextBox
>
</
div
>
Users can edit the number of Oranges and divide Apples/Oranges on button click. The button click event handled in the ascx.cs file, which does the math and updated the value displayed in txtApples.
Now, I want to add a Reset button to the UserControl. When clicked, the original Apple value will display in txtApples. Seems like this value would be availble in the Edited Grid Item as described here:
Accessing the edited grid item from the user control
When RadGrid loads the UserControl Edit Form, the UserControl has full access to the properties of the grid item in which it is loaded. Inside theUserControl, you can access the grid item using the Parent.NamingContainer property:
GridEditableItem editedItem = this.Parent.NamingContainer;
Once you have a reference to the GridEditableItem object, you can access any of its properties, such as cell text values, the DataItem object (available in DataBinding event handler), and so on.
How can I access the Apple cell text value?