Hello!
I have a grid with RadComboBox in an EditItemTemplate:
<telerik:GridTemplateColumn DataField="Value" HeaderText="Wert"> <EditItemTemplate> <telerik:RadComboBox ID="cboFeatureValue" runat="server" DataSourceID="odsFeatureValueList" SelectedValue='<%# Bind("Value") %>' DataTextField="Text" DataValueField="Value" Skin="Default"> </telerik:RadComboBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="lblFeatureValue" runat="server" Text='<%# Eval("Value") %>'></asp:Label> </ItemTemplate></telerik:GridTemplateColumn>
On some rows, depending on the data, I need a TextBox instead of the RadComboBox. Any idea how to achieve this?
I tried adding the TextBox in the EditITemTemplate and disabling the not wanted control:
<asp:TextBox runat="server" Text='<%# Bind("Value") %>' ID="txtFeatureValue"/>and in here I disable the not wanted control:
Private Sub grdFeatureList_ItemDataBound(sender As Object, e As GridItemEventArgs) Handles grdFeatureList.ItemDataBound If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then Dim dataItem As GridEditableItem = TryCast(e.Item, GridEditableItem) If _FeatureParameter.Contains("Enum") Then Dim textBox As TextBox = CType(dataItem.FindControl("txtFeatureValue"), TextBox) textBox.Enabled = False textBox.Visible = False Else Dim radComboBox As RadComboBox = CType(dataItem.FindControl("cboFeatureValue"), RadComboBox) radComboBox.Enabled = False radComboBox.Visible = False End If End IfEnd Sub
The problem is, that the Selecting event of the RadComboBox is called before I can disable the ComboBox. And as I don't have any data for the combo box I get an "Selection out of range" exception.
Thanks for helping!
Regards,
Tonino.
