Typed list

Posts   
 
    
Posts: 54
Joined: 22-Jun-2010
# Posted on: 19-Aug-2010 11:18:08   

LLBLGEN 3.0

I have two comboboxes menu sub group and menu group which I am populating using typedlist as per below code. works absolutely fine and I got this easily

var adapter = new DataAccessAdapter(); IRelationPredicateBucket filter = menugroupsubgroup.GetRelationInfo(); filter.PredicateExpression.Add(MenusubgroupFields.Flag == StandardFlag.recordvalidflag); filter.Relations.Add(MenusubgroupEntity.Relations.MenugroupEntityUsingMenugroupId); ISortExpression sorter = new SortExpression(MenusubgroupFields.Description | SortOperator.Ascending); adapter.FetchTypedList(menugroupsubgroup.GetFieldsInfo(), menugroupsubgroup, filter,0, sorter,false); cmbmenusubgroupid.DataSource = menugroupsubgroup; cmbmenusubgroupid.ValueMember = "MENUSUBGROUPID"; cmbmenusubgroupid.DisplayMember = "MENUSUBGROUPDESCRIPTION"; cmbmenusubgroupid.SelectedIndex = -1;

            cmbmenugroupid.BindingContext = new BindingContext();
            cmbmenugroupid.DataSource = menugroupsubgroup;
            cmbmenugroupid.ValueMember = "MENUGROUPID";
            cmbmenugroupid.DisplayMember = "MENUGROUPDESCRIPTION";
            cmbmenugroupid.SelectedIndex = -1;

Now, When I select menu subgroup from combobox, corresponding menu group does not appear in menu group combo box. Any thing extra to be done ? I mean menugroup related to selected subgroup only to be displayed

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 19-Aug-2010 20:31:37   

Do you mean you want the second combo box to display the list filtered according to the selection in the first combo box...? If so you will have to do this manually, there is no inbuilt behavior to do this.

Matt

Posts: 54
Joined: 22-Jun-2010
# Posted on: 20-Aug-2010 06:41:38   

MTrinder wrote:

Do you mean you want the second combo box to display the list filtered according to the selection in the first combo box...? If so you will have to do this manually, there is no inbuilt behavior to do this.

Matt

Exactly. You got that right. But even if i have to do manally how do I do it was I was not able to understand

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 20-Aug-2010 10:42:58   

You can handle the selectedIndexChanged of the first DDL and there you should populate the second DDL filtered by the selected value of the first DDL.

This can also be managed at design, by using LLBLGenProDataSource and SelectParameters (web app.) or by using a BindingSource controls (windows app.).

Either way you should check the databinding examples posted on our web site to see how master - detail databainding can be done.

Posts: 54
Joined: 22-Jun-2010
# Posted on: 20-Aug-2010 13:12:44   

Walaa wrote:

You can handle the selectedIndexChanged of the first DDL and there you should populate the second DDL filtered by the selected value of the first DDL.

This can also be managed at design, by using LLBLGenProDataSource and SelectParameters (web app.) or by using a BindingSource controls (windows app.).

Either way you should check the databinding examples posted on our web site to see how master - detail databainding can be done.

True. Had tried this. Though it worked there was some minor issue. Let me check and post the problem I faced by using above method

Posts: 54
Joined: 22-Jun-2010
# Posted on: 21-Aug-2010 06:18:19   

Walaa wrote:

You can handle the selectedIndexChanged of the first DDL and there you should populate the second DDL filtered by the selected value of the first DDL.

This can also be managed at design, by using LLBLGenProDataSource and SelectParameters (web app.) or by using a BindingSource controls (windows app.).

Either way you should check the databinding examples posted on our web site to see how master - detail databainding can be done.

Before posting on forum I had tried this in selectedIndexChanged

var datasourcemenugroup = new EntityCollection(new MenugroupEntityFactory()); filtermenusubgroup.Clear(); filtermenusubgroup.Add(MenusubgroupFields.MenusubgroupId == int.Parse(cmbmenusubgroupid.SelectedValue.ToString())); bucketmengroup.PredicateExpression.Add(filtermenusubgroup); bucketmengroup.Relations.Add( MenugroupEntity.Relations.MenusubgroupEntityUsingMenugroupId); bucketmengroup.PredicateExpression.Add(MenugroupFields.Flag == StandardFlag.recordvalidflag); adaptermengroup.FetchEntityCollection(datasourcemenugroup, bucketmengroup, 0, new SortExpression( MenugroupFields.Description | SortOperator.Ascending)); cmbmenugroupid.DataSource = datasourcemenugroup; cmbmenugroupid.ValueMember = "MENUGROUPID"; cmbmenugroupid.DisplayMember = "DECRIPTION"; cmbmenugroupid.SelectedIndex = -1;

Now, this works fine. Problem is, I dont want the code to go into this loop when menusubgroup is not selected or invalid value is entered. Because I get error " on form load" error Message: at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) at System.Int32.Parse(String s)

Now, When I try adding before "var" any of the following code Nothing gets loaded in combo if(cmbmenusubgroupid.SelectedIndex==0) return; if(cmbmenusubgroupid.SelectedIndex==-1) return;

For testing purpose I again tried

var index = int.Parse(cmbmenusubgroupid.SelectedValue.ToString()); MessageBox.Show(Convert.ToString(index));

Now during form load it shows selected value as "ClubCentricHelper.EntityClasses.MenusubgroupEntity". once form loaded then it works right. Means during load of first combobox selectedIndexChanged is triggered which is causing the problem

I beleive this is what is causing the problem. But how do i resolve this

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 22-Aug-2010 22:06:24   

You have to test the value of SelectedIndex or SelectedValue when it loads the first time, then you can add a restriction to that value (like your IFs above).

David Elizondo | LLBLGen Support Team