SalesLogix web has a “ComboBox” control which is actually rendered on the deployed page as an ASP ListBox control. In the Application Architect you can see the control has two properties for Value and Text. The value
One would assume SalesLogix would have a built in property exposed to allow you to add items to the ComboBox and to set the Text and Value portions of said items, and they do, sort of. If you go to a code editor in the Application Architect and start looking at the attributes and methods exposed for the ComboBox you will see an Items collection with an Add method. Looks like we have it.
As the code help shows the add method takes two parameters on for the text string and one for the value string. The only problem with this is if you do so, something like:
You will get an error when you visit the page on the web site along the lines of:
A smart part associated with this page has failed to load: c:InetpubwwwrootsiteSLXClientSmartPartsTicketTicketCall.ascx(124): error CS1501: No overload for method ‘Add’ takes ‘2’ arguments
If you pass in instead just:
This will work, however both the text and value properties of the list item will be “Some Text”. Not good if you need to know a specific ID value of a list item chosen.
So what gives? Well it turns out what you actually need to pass into the Add method is a ListItem. The list item can then have two values, one for text and one for value. So the proper format of the add command would be:
cboProblem.Items.Add( new System.Web.UI.WebControls.ListItem(“Some text”,”ID123”));
Now that you have populated the list with your various entries and defined the text and value portions of the items you can retrieve them like so:
//get selected item’s value
string val = cboProblem.Items[cboProblem.SelectedIndex].Value
//get selected item’s text
string disp = cboProblem.Items[cboProblem.SelectedIndex].Text