Sep 10, 2013, 1:29 PM
[CLOSED] Combobox - DisplayField set in code behind
Hi, how are you? I'm trying to set the DisplayField of a combobox in codebehind depending of another field in the same form. The comobobox works fine the first time the displayfield value is set, but it looks like the value of displayfield doesn't change from second time on.
Here is the code:
Thank you in advance
Here is the code:
<ext:RadioGroup ID="rgrEmpresaParticular" runat="server" ColumnsNumber="2" AutomaticGrouping="false">
<Items>
<ext:Radio ID="rbtEmpresa" runat="server" Name="EmpresaParticular" InputValue="1" BoxLabel="Empresa">
</ext:Radio>
<ext:Radio ID="rbtParticular" runat="server" Name="EmpresaParticular" InputValue="2" BoxLabel="Particular">
</ext:Radio>
</Items>
<DirectEvents>
<Change OnEvent="EmpresaParticularModificado"></Change>
</DirectEvents>
</ext:RadioGroup>
<ext:ComboBox
ID="ddlClientes"
runat="server"
ValueField="ID_CLIENTE"
DisplayField="NOMBRE_CLIENTE"
Editable="false"
NoteAlign="Top" Note="Clientes">
<Store>
<ext:Store
runat="server"
ID="storeClientes"
AutoLoad="false" >
<Model>
<ext:Model ID="Model3" runat="server" IDProperty="ID_CLIENTE">
<Fields>
<ext:ModelField Name="ID_CLIENTE" Type="Int" ServerMapping="ID_CLIENTE" />
<ext:ModelField Name="CODIGO_AGENCIA" Type="String" ServerMapping="CODIGO_AGENCIA" />
<ext:ModelField Name="NOMBRE_CLIENTE" Type="String" ServerMapping="NOMBRE_CLIENTE" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
</ext:ComboBox>
Public Sub EmpresaParticularModificado(ByVal sender As Object, ByVal e As Ext.Net.DirectEventArgs)
Dim empresaParticular As Integer = Integer.Parse(rgrEmpresaParticular.CheckedItems(0).InputValue)
RellenarComboClientes(empresaParticular)
End Sub
Private Sub RellenarComboClientes(ByVal empresaParticular As Integer)
ddlClientes.Items.Clear()
ddlClientes.Text = ""
Dim InterfazClientes As New Negocio.InterfazClientes()
Try
Dim tablaClientes As Object = InterfazClientes.RecuperarClientes(empresaParticular)
Select Case empresaParticular
Case 1
ddlClientes.DisplayField = "CODIGO_AGENCIA"
storeClientes.DataSource = tablaClientes
storeClientes.DataBind()
Case Else
ddlClientes.DisplayField = "NOMBRE_CLIENTE"
storeClientes.DataSource = tablaClientes
storeClientes.DataBind()
End Select
Catch ex As Exception
MostrarPanelMensaje("alert alert-error", "No se ha podido leer la base de datos de clientes. Error: " & ex.Message)
End Try
End Sub
Am I missing something?Thank you in advance
Last edited by Daniil; Sep 11, 2013 at 2:03 PM.
Reason: [CLOSED]