• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 237
  • Last Modified:

Getting the default value of a databound combobox

I have a combobox that is populated like this

                Me.cbReportParam.DisplayMember = "Name"
                Me.cbReportParam.ValueMember = "Name_ID"
                Me.cbReportParam.DataSource = ds.Tables("Names")

It populates correctly. So the first selection is "Adam". How do I get the name to my variable strName?
When I try strName = me.cbReportParam.SelectedItem it returns {System.Data.DataRowView}
I dont want to hardcode "Adam" because a name could be added before it later on.
0
bertino12
Asked:
bertino12
  • 3
  • 3
1 Solution
 
Stephen MandersonCommented:
Hi there,

use the .SelectedText property for this

Regards
Steve
0
 
bertino12Author Commented:
It returns ""
0
 
Stephen MandersonCommented:
Try

Me.StrName = Me.cbReportParam.SelectedItem.ToString

Regards
Steve
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
bertino12Author Commented:
That gave me "System.Data.DataRowView"


strName = CType(cbReportParam.SelectedItem, DataRowView).Item("Name")
finally got it working
0
 
Stephen MandersonCommented:
Good to hear it,

Weird I couldnt recreate the problem..

I could get it to show the string with either selectedtext or selecteditem with it being databound

Anyways all the best!
Steve


0
 
bertino12Author Commented:
Thanks for the time :P
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now