Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / February 2005

Tip: Looking for answers? Try searching our database.

Combo Box Functionality

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Terrance - 27 Feb 2005 20:27 GMT
I'm hoping someone can help me with an issue. What's happening is I'm binding
two datasets to a combo box from a dataset. The code is as follows:
Try
           prodSet = New DataSet
           agenSet = New DataSet

           'DataBind the agency info and product info.
           agenSet = sqlClass.LoadProductList("agencies")
           cboAgency.DataSource = agenSet.Tables(0)
           cboAgency.ValueMember = _
               Trim(agenSet.Tables(0).Columns("agencyid").ToString())
           cboAgency.DisplayMember = _
               Trim(agenSet.Tables(0).Columns("agencyname").ToString())

           prodSet = sqlClass.LoadProductList("product")
           cboProduct.DataSource = prodSet.Tables(0)

           'This is the value member that the db understands.
           cboProduct.ValueMember = _
           prodSet.Tables(0).Columns("listid").ToString

           'This is the value that the user will see.
           cboProduct.DisplayMember = _
            prodSet.Tables(0).Columns("product").ToString

As you can see I try to Trim any trailing white spaces; however, when I load
the form the data displays the end of the displaymembers in other words  the
white spaces. All of the displaymembers show up but when clicking on the
combo box and choosing a value the combo box highlights everything including
the spaces(if that make sense) So, when the user chooses a value the combo
box is highlighted blue, the values doesn't actually show until the combo box
loses focus. Instead highlighting just he word/text in the combobox
everything is highlighted including the white area. What am I doing wrong?
Please help.
Signature

TC

Terrance - 28 Feb 2005 12:47 GMT
Ok, I figured the answer out for anyone who's interested. As I was driving in
to work today; and being the fact that I don't have a radio in my car I
started thinking about this problem..then all of a sudden WHAM!! it hit me. I
knew the dataset was placing the data into a datatable including trailing
white spaces so since I was using Stored Procedures in this project I  
realized the problem was in my  procedure. I had to do a RTrim(fieldname) in
the sql statement that I had for the white spaces to show up. Silly me....

> I'm hoping someone can help me with an issue. What's happening is I'm binding
> two datasets to a combo box from a dataset. The code is as follows:
[quoted text clipped - 30 lines]
> everything is highlighted including the white area. What am I doing wrong?
> Please help.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.