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

[Solved] Retrieve control from <EditItemTemplate> when NOT in Edit Mode

1 Answer 75 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 02 Oct 2009, 08:31 PM
Hi community,

I had a simple question. Is it possible to retrieve a RadComboBox control (or any other control)
from the <EditItemTemplate> of a GridTemplateColumn when the Grid is
NOT in Edit Mode?


Or To Explain Further if necessary:

The issue is that I am importing from an excel spreadsheet into a grid. One of the grids
has a <GridTemplateColumn> with a Label control in the <ItemTemplate>
and a RadComboBox in the <EditItemTempalte>. The 'DataTextField' of the combo
box is something like 'product_name', the 'DataValueField' is something like 'product_id'.

code:

 

<telerik:GridTemplateColumn HeaderText="Product" UniqueName="prodDropDown">

 

<EditItemTemplate>

 

<telerik:RadComboBox ID="prodDropDown"

 

DataSourceId="prodDataSource"

 

DataTextField="prod_name"

 

DataValueField="prod_id"

 

Visible="true" runat="server" />

 

</EditItemTemplate>

 

<ItemTemplate>

 

 

 

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

 

</ItemTemplate>

 

</telerik:GridTemplateColumn>

 

 



The problem is that the user only knows the 'product_name' values so that's what they put
in the spreadsheet.

After they do the import, a grid appears with all the data (for review purposes) along with a 'Commit To Database' button.
I am using 'GridTemplateColumn ' because I am trying to display the value of 'Product' to the user as just a 'Label' as opposed to a 'RadComboBox' control.

The problem is I need to get at the <EditItemTemplate> part to set the product_id after the Excel is imported.
So far I haven't been able to get the combo box control unless the grid is in edit mode.

If anybody could help, it would be appreciated. Thanks!

1 Answer, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 07 Oct 2009, 10:29 AM
Hello Richard,

I am afraid that the controls in the EditItemTemplate are available only while editing. You cannot access them in non-edit mode.
In order to achieve your goal I suggest that you handle the ItemDataBound event and if an item is in edit mode, then find the desired controls and set its value.

I hope this helps.

Greetings,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Richard
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question
or