Solved

Getting the default value of a databound combobox

Posted on 2008-06-10
6
227 Views
Last Modified: 2010-04-23
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
Comment
Question by:bertino12
  • 3
  • 3
6 Comments
 
LVL 19

Expert Comment

by:Stephen Manderson
Comment Utility
Hi there,

use the .SelectedText property for this

Regards
Steve
0
 

Author Comment

by:bertino12
Comment Utility
It returns ""
0
 
LVL 19

Expert Comment

by:Stephen Manderson
Comment Utility
Try

Me.StrName = Me.cbReportParam.SelectedItem.ToString

Regards
Steve
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Accepted Solution

by:
bertino12 earned 0 total points
Comment Utility
That gave me "System.Data.DataRowView"


strName = CType(cbReportParam.SelectedItem, DataRowView).Item("Name")
finally got it working
0
 
LVL 19

Expert Comment

by:Stephen Manderson
Comment Utility
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
 

Author Comment

by:bertino12
Comment Utility
Thanks for the time :P
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now