I have the following ASPX page:
The
I'm thinking this has something to do with databinding, but I'm stuck on how to correctly databind these two controls.
(PS: What I'm basically trying to do is to set the textbox value based upon a selection from the combo box)
<script type="text/javascript"> function SectorChanged(sender, eventArgs) { var selectedItem = eventArgs.get_item(); var selectedItemText = selectedItem.get_element().childNodes[1].innerText;
var textInput = $get('<%= companyGicsFormView.FindControl("txtSectorText").ClientID %>'); textInput .value = selectedItemText ; textInput .text = selectedItemText ; } function OnClientDropDownOpeningHandler(sender, eventArgs) { sender.requestItems("", false); }</script><asp:FormView runat="server" ID="formView" DefaultMode="Edit"> <EditItemTemplate> <telerik:RadComboBox runat="server" ID="cboTest" DataSourceID="customDs" DataTextField="Sector" DataValueField="Sector" SelectedValue='<%# Bind("Sector") %>' OnClientSelectedIndexChanged="SectorChanged" HighlightTemplatedItems="true" AllowCustomText="false" EnableLoadOnDemand="false" OnClientDropDownOpening="OnClientDropDownOpeningHandler"> <ItemTemplate> <%# DataBinder.Eval(Container.DataItem, "Sector") %> <span style="display:none;"><%# DataBinder.Eval(Container.DataItem, "SectorText")%></span> </ItemTemplate> </telerik:RadComboBox> <telerik:RadTextBox ID="txtSectorText" runat="server" Text='<%# Bind("SectorText") %>' MaxLength="255" ReadOnly="False" Enabled="False" /> </EditItemTemplate></asp:FormView>The
cboTest Combo Box is being populated correctly. The txtSectorText is also updated when I select something from the combobox. However: Neither the combo box value nor the textbox value are saved to the datasource.I'm thinking this has something to do with databinding, but I'm stuck on how to correctly databind these two controls.
(PS: What I'm basically trying to do is to set the textbox value based upon a selection from the combo box)