Populating DropDownList
Hello Everyone and thanks for your help in advance. I am developing a class library that reads a SQL Server table of names and ID's. I want to populate a dropdownlist with the data, however, names in the table may appear more than once. I only want to display the name in the dropdownlist once. My initial thought wat to create an arraylist, then loop through each record, adding a new name upon each new name encountered. But I want the name to display in the dropdownlist, but the associated value to be the IDNumber for the particular name. This would be pretty straightforward if I was doing this in a code-behind, simply adding to the list as each record was read. But since this is a separate class, I have to return something that can be bound to the dropdownlist control. I am not eactly sure how to go about accomplishing this. Any help would be greatly appreciated. Thanks.
|