Solved

Getting the default value of a databound combobox

Posted on 2008-06-10
6
231 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
ID: 21751371
Hi there,

use the .SelectedText property for this

Regards
Steve
0
 

Author Comment

by:bertino12
ID: 21751391
It returns ""
0
 
LVL 19

Expert Comment

by:Stephen Manderson
ID: 21751438
Try

Me.StrName = Me.cbReportParam.SelectedItem.ToString

Regards
Steve
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Accepted Solution

by:
bertino12 earned 0 total points
ID: 21751541
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
ID: 21751564
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
ID: 21751720
Thanks for the time :P
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Sql server insert 13 36
Write to a printer using vb.net 9 38
Convert Ctime to date time in textfile? 7 28
how to hit button in form and close application from main() 4 20
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used.

792 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