|
-
Jan 29th, 2004, 04:08 AM
#1
Thread Starter
Fanatic Member
Combo display & value [RESOLVED]
Hi All
Ive got a combo box which is being filled by a dataset i want to show the text value from one column but when a user makes their selection i want to pass over the datasets record Id rather than the text value (How is this done)
Heres the vb code for filling the combo
VB Code:
Private Sub Designer_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim objData As New NewForestMortgagesAPP.DesignerDI.GetDI
Me.cboLetter.DisplayMember = "LetterName"
Me.cboLetter.DataSource = objData.GetDataSet.Tables(0)
End Sub
I just wana know the correct way of doing this ?
Many Thanks
Last edited by carlblanchard; Jan 29th, 2004 at 11:41 AM.
I am curretly building a defect management system for software and web developers,
If you wana try it out (beta test) and keep it for free just send me a message
-
Jan 29th, 2004, 09:54 AM
#2
Frenzied Member
try something like this
VB Code:
Dim objData As New NewForestMortgagesAPP.DesignerDI.GetDI
Me.cboLetter.DataSource = objData.GetDataSet.Tables(0)
Me.cboLetter.DataValueField = "RecordId"
Me.cboLetter.DataTextField = "LetterName"
Me.cboLetter.DataBind()
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
-
Jan 29th, 2004, 10:02 AM
#3
Thread Starter
Fanatic Member
is that for asp.net because theres no such property of DataValueField within a win form combo box
I am curretly building a defect management system for software and web developers,
If you wana try it out (beta test) and keep it for free just send me a message
-
Jan 29th, 2004, 10:55 AM
#4
You would do like Memnoch1207 showed only the Property should be "ValueMember" and then to get the value use the SelectedValue property instead of the Text property.
-
Jan 29th, 2004, 11:40 AM
#5
Thread Starter
Fanatic Member
Yep i done it with ValueMember = "ColumnName"
I was trying to get the value by using ValueMember as well (when its simply SelectedValue that returns the correct ID )
I must say ( this method of binding to control ) is absolutly wicked.
My Code is looking cleaner and more understandable every single day Thanks All
I am curretly building a defect management system for software and web developers,
If you wana try it out (beta test) and keep it for free just send me a message
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|