Question : ASPNET/C# - Listbox question color - tricky

Hello all,

I have two listboxes:

Listbox Customer:
DataTextField:  CustomerName
DateValueField: CustomerID

Listbox CustomerOrder
DataTextField:  OrderNumber
DataValueField: OrderID

So what I am trying to do is, the Listbox Customer after I load it, I loop through each item and assign a random color to the "Item.BackColor".   Now the tricky part is when the CustomerOrder listbox is loaded, I have the CustomerID but can I assign that to another attribute other than the Text and Value field?  Then what I need to do is somehow loop through the listbox ietms in the CustomerOrder listbox match the new attribute CustomerID to the listbox Customer and set the item.backcolor of that item to whatever it is in the Customer listbox.  

Listbox Customer:
Customer Name  CustomerID
ABC Customer     12           item.backcolor = color.red;
DEF Customer      13           item.backcolor = color.blue;

1 to many here

Listbox CustomerOrder
OrderNumber      OrderId    [some other attribute for customer id]
1234                   3234       12                    item.backcolor = color.red;
2546                   4554       12                    item.backcolor = color.red;
5652                   7898        13                   item.backcolor = color.blue;
5564                   8921        13                   item.backcolor = color.blue;

hopefully not confused at this point :).

Answer : ASPNET/C# - Listbox question color - tricky

answer is no, it has 2 property, text and value

maybe in the second listbox, you can set value = OrderId + + "|" + CustomerID;

so you will have "3234|12" in the value, so you can loop and get the value, split, check the second part
if you wish you can set it to order id after changing the color

for each item as listitem in lbCustomerOrder {
  if (item.value.split("|")[1] = customer id ...item.backgroud = ...
  item.value = item.value.split("|")[0]
}

may have some syntax errors...
Random Solutions  
 
programming4us programming4us