PDA

View Full Version : [CLOSED] Get Selected Combo Box without selected first



redi
Nov 28, 2013, 9:42 AM
Hai..

I have some case here. I create Form Edit using a combobox field.When i try to edit the form without change anything in combox, the return value from combobox is the text that display in combobox field but if i do a change combobox the value is return 1 or 0. My combo box value i set to 1 and 0 and the text value is something text. i attachment image above about my problem.

This is my formpanel script aspx :


<ext:FormPanel ID="frmPanel1"
runat="server"
Title="Personal Data"
BodyPadding="10"
Layout="FormLayout">
<Defaults>
<ext:Parameter Name="LabelWidth" Value="75" Mode="Raw" />
</Defaults>
<Items>
<ext:TextField ID="txtName" runat="server" FieldLabel="Name" AllowBlank="false" />
<ext:TextField ID="txtRFID" runat="server" FieldLabel="RFID" AllowBlank="false" />
<ext:ComboBox ID="type"
runat="server"
Name="type"
EmptyText="Select Type..."
FieldLabel="Type" ForceSelection="false">
<Items>
<ext:ListItem Text="Operator" Value="1" />
<ext:ListItem Text="Mechanic" Value="0" />
</Items>
</ext:ComboBox>
<ext:Checkbox ID="active" runat="server" FieldLabel="Active ? " />
<ext:TextField ID="txtSMUHours" runat="server" FieldLabel="SMU Hours" />
</Items>
</ext:FormPanel>


And this is the form data come in code behind :


Dim employeeID As String = e.ExtraParams("SN")
Dim ds As New DataSet

ds = BL.blFMGetOperatorSelect(Me.Session("AuthState"), employeeID)

For i = 0 To ds.Tables(0).Rows.Count - 1
With ds.Tables(0).Rows(i)
txtName.Text = .Item(1)
txtRFID.Text = .Item(4)
type.SetValue(.Item(2)) <--- combo box value from
If (.Item(3)) Then
active.Checked = True
Else
active.Checked = False
End If
txtSMUHours.Text = .Item(10)
End With
Next

thanks for your attention and support.

Regards,
Redi

Daniil
Nov 28, 2013, 1:35 PM
Hi @redi,

I am pretty sure there is mismatching of types.

These Values

<ext:ListItem Text="Operator" Value="1" />
<ext:ListItem Text="Mechanic" Value="0" />
are strings.

But here

type.SetValue(.Item(2))

I guess, a numeric type like int.

Please try this:

<ext:ListItem Text="Operator" Value="1" Mode="Raw" />
<ext:ListItem Text="Mechanic" Value="0" Mode="Raw" />

This way the Values will be rendered as int, not as strings.

redi
Nov 29, 2013, 2:55 AM
Hai Daniil,

thanks for your answer. I try u'r solution but when i click details the combo box text turning to false or true text. How to change text false and true so i can keep display the text of my combo box its Operator or is Mechanic ?

Regards,
Redi

Daniil
Nov 29, 2013, 4:18 AM
Hmm, no idea.

Please provide a full test case to reproduce.