Results 1 to 2 of 2

Thread: [2008] Do you bind to just TEXT for a COMBOBOX

  1. #1

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    [2008] Do you bind to just TEXT for a COMBOBOX

    I've got a combobox - style DropDownList.

    Three options - blank, EMAIL or PHONE - these three are set at design time.

    Do I just bind the TEXT property of the COMBOBOX to the field in the DATATABLE?

    This appears to be working fine - but I'm a bit confused about the purpose of SELECTEDVALUE in all this. I'm not binding to that.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] Do you bind to just TEXT for a COMBOBOX

    While the Text property is not strictly wrong in this case, it is more for use when the DropDownStyle is DropDown. It allows you to get the text that the user typed in when an item has not been selected from the list. When the DropDownStyle is DropDownList I would always use SelectedValue.

    If you're adding strings to the list directly then you could use SelectedItem too but, again, SelectedValue is the "most correct". You should also note that, when you bind to the control and set a ValueMember, the SelectedValue is the only property that you can use to get the selected value from that column.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width