Combo values based on another combo value


Author
Message
Juan Carlos Pazos
Juan Carlos Pazos
StrataFrame User (310 reputation)StrataFrame User (310 reputation)StrataFrame User (310 reputation)StrataFrame User (310 reputation)StrataFrame User (310 reputation)StrataFrame User (310 reputation)StrataFrame User (310 reputation)StrataFrame User (310 reputation)StrataFrame User (310 reputation)
Group: Forum Members
Posts: 144, Visits: 227
Hi

I already use your model and works fine with two combos, but now I try to put three combos (example: one for Country, another for State and final the City).

Using the same solution for two, in the last combo City it alwas give an error: {"The CurrentRow for table '[dbo].[States_Pub]' could not be evaluated because the CurrentRowIndex is out of range.  Business object record count: 0.  CurrentRowIndex: -1."}

What I have is the first (country) combo and second combo (states) is exactly as you indicate me before and works fine.

How can put three combos what depend of the previous value selected.

Regards

Smile Everything is possible, just keep trying...

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Good to hear Smile
Juan Carlos Pazos
Juan Carlos Pazos
StrataFrame User (310 reputation)StrataFrame User (310 reputation)StrataFrame User (310 reputation)StrataFrame User (310 reputation)StrataFrame User (310 reputation)StrataFrame User (310 reputation)StrataFrame User (310 reputation)StrataFrame User (310 reputation)StrataFrame User (310 reputation)
Group: Forum Members
Posts: 144, Visits: 227
Edji, Trent

Thanks for your support, following your insructions the combos work as needed.

Regards

Smile Everything is possible, just keep trying...

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
All good advice...the only thing that I see is that you need to supply the second parameter also if you are using the CopyDatafrom method.  The ListPopulating event would look something like this:

e.Parameters(0).Value = MyBO
e.Parameters(1).Value = MicroFour.StrataFrame.Business.BusinessCloneType.ClearAndFillWithDefaultView

You have to supply all of the parms to match the method that is being executed on the BO.

Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hola Juan Carlos,

A couple of things:  You don't need to have a BO in the main form for a lookup comboboxes, so in your case you don't need the BOs for the States and Cities in the form. 

If all you need is to filter the Cities by the data selected in the State combo, setup the Cities combo as follow:

ComboBoxCities.PopulationDataSourceSettings = CitiesBO.FillByState(System.Int32)  (which I believe you have it that way Smile)

In the ComboBoxCities.ListPopulating Event have a code like this, which is the step you are missing:

Private Sub ComboBoxCities_ListPopulating(ByVal e As MicroFour.StrataFrame.UI.ListPopulatingEventArgs) Handles ComboBoxCities.ListPopulating

     If Me.StatesBO.Count > 0 Then

          e.Parameters(0).Value = Me.StatesBO.YourStatePKFieldValue

     Else

          e.Parameters(0).Value = 0

     End If

End Sub

Private Sub cboStates_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboStates.SelectedIndexChanged

     ' This is needed to show the correct filtered Cities in the combo.

      Me.ComboBoxCities.Requery()

End Sub



Edhy Rijo

Juan Carlos Pazos
Juan Carlos Pazos
StrataFrame User (310 reputation)StrataFrame User (310 reputation)StrataFrame User (310 reputation)StrataFrame User (310 reputation)StrataFrame User (310 reputation)StrataFrame User (310 reputation)StrataFrame User (310 reputation)StrataFrame User (310 reputation)StrataFrame User (310 reputation)
Group: Forum Members
Posts: 144, Visits: 227
Hi

Sorry for the last post, It was completly wrong.

Hope this time I can explain better.

I want to fill a Combo according the value of another Combo.

I have this scenario

Table States

IdState - Int32

Statename - String

Table Cities

IdCity - Int32

IdState - Int32

CityName - String

Table Streets

IdStreets - Int32

IdCity - Int32

IdState - Int32

StreetName - String

The three tables have relations defined.

I create a form to mantein the states, the a form to mantein the cities and all fine.

I create a new form to mantein the streets, and here is my problem. In this user first select the state from a combo and the according to the selected state a second combo must be filled with only the cities of the state selected in the first combo.

There are three BO, one for the form, another for the States and a thierd one for the cities.

In the BO of the cities I have this:

Public Sub FillByState(ByVal State As Integer)...

loCommand.CommandText = "SELECT * FROM Cities WHERE IdState = @IdSate"

...

End Sub

The fill is copy of the one used in the tutorial. The PopulationDataSourceSettings for the CitiesBO are set to execute the FillByState: CitiesBO.FillByState(System.Int32) and PopulateOnFormLoad is FormLoad

In the combo of State I add this code for the SelectedvalueChanged event

Me.CitiesBO.FillBySate(Me.ComboBoxState.SelectedValue)

Me.ComboBoxCities.Requery()

But when I select a state the combo for the cities is not filled.

What do I need to do?

Regards



Smile Everything is possible, just keep trying...
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search