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