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

Accessing Editmode data items in code behind

1 Answer 17 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Derek
Top achievements
Rank 1
Derek asked on 17 Oct 2008, 03:34 PM
I've been pulling my hair out reading every article on how to access controls that are in edit mode, however I cannot find an example on how to access the actual data item in the code behind:

eg:  I want to access the value of the inline <%# Eval("title") %> in my VB code on an ItemCreated event *** NOT *** the value of lblTitle.

<asp:Label runat="server" ID="lblTitle" Text='<%# Eval("title") %>' /> 

Any help would be much appreciated.  Thanks.

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 17 Oct 2008, 04:21 PM
Hello Derek,

In order to extract the value you should use two-way binding as shown below (Bind instead of Eval):
 <asp:Label runat="server" ID="lblTitle" Text='<%# Bind("Name") %>' /> 

if (e.Item.IsInEditMode) 
    Hashtable hashtable = new Hashtable(); 
    (e.Item as GridEditFormItem).ExtractValues(hashtable); //or e.Item as GridDataItem 
    string myString = hashtable["Name"].ToString(); 

Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Derek
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or