G
Guest
I have a listbox who's dataSource is an array of Classes of the type
Discount. and this listbox is bound to a Customer's Discount property.
Customer c = CustomerFactory.GetInstance(2342);
Dicsount[] d = DiscountFactory.GetAll();
ListBox1.DataSource=d;
ListBox1.DisplayMember="Description";
Listbox1.DataBindings.Add("SelectedItem",c,"Discount");
This works beautifully. However, for some customers there will be no
discount. In this case, I would need a "No Discount" option in my listbox
whose value is null so that the customer.Discount property is set to null.
Can this be done somehow? Can you add an item to a listbox os combobox that
sets a databound property to null?
I know that I could ass a Discount instance to the array whose description
is "No Discount." However, that's kind of sloppy. There is a lot of logic in
my app that checks for things like "if(myCustomer.Discount==null)" and
checking for "if(myCustomer.Discount.Description=="No Discount")" is
effectively hard-coding database values into your app (baaaaad idea)
So, any thought? anyone?
Discount. and this listbox is bound to a Customer's Discount property.
Customer c = CustomerFactory.GetInstance(2342);
Dicsount[] d = DiscountFactory.GetAll();
ListBox1.DataSource=d;
ListBox1.DisplayMember="Description";
Listbox1.DataBindings.Add("SelectedItem",c,"Discount");
This works beautifully. However, for some customers there will be no
discount. In this case, I would need a "No Discount" option in my listbox
whose value is null so that the customer.Discount property is set to null.
Can this be done somehow? Can you add an item to a listbox os combobox that
sets a databound property to null?
I know that I could ass a Discount instance to the array whose description
is "No Discount." However, that's kind of sloppy. There is a lot of logic in
my app that checks for things like "if(myCustomer.Discount==null)" and
checking for "if(myCustomer.Discount.Description=="No Discount")" is
effectively hard-coding database values into your app (baaaaad idea)
So, any thought? anyone?