I have a normal RadGrid and in that grid columns like this:
| <telerik:GridTemplateColumn |
| HeaderText="MyColumn" |
| UniqueName="MyColumn"> |
| <ItemTemplate> |
| <asp:Label ID="MyColumnLabel" runat="server" Text='<%# Eval("MyColumn") %>'></asp:Label> |
| </ItemTemplate> |
| <EditItemTemplate> |
| <telerik:RadComboBox |
| ID="Domains" |
| DataTextField="MyColumn" |
| DataValueField="MyColumnID" |
| Runat="server"> |
| </telerik:RadComboBox> |
| </EditItemTemplate> |
| </telerik:GridTemplateColumn> |
Then in the code-behind:
| protected void MyGrid_OnItemDataBound(object sender, GridItemEventArgs e) |
| { |
| if ((e.Item is GridEditableItem) && e.Item.IsInEditMode) |
| { |
| GridEditableItem gridEditableItem = (GridEditableItem)e.Item; |
| RadComboBox myComboBox = (RadComboBox)gridEditableItem.FindControl("MyComboBox"); |
| this.businessData = new BusinessData(); |
| // Don't worry about this. It pulls data from the business layer and databinds the ComboBox. |
| TelerikHelper.BindRadComboBox(myComboBox, businessdataData.Select(), false); |
| } |
| } |
Everything works fine as is. In non-edit view, the correct value is displayed and in edit view, the combobox is displayed, populated with values.
But I also want to set the selected item in the databound dropdown to the text value set in MyColumnLabel.
I must be having an off-day because I simply cannot work out how to do it :(
Can anyone enlighten me? I've been through any number of examples on the Telerik site with no luck.
Regards,
Richard