Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a combobox as a dropdown showing customername and combobox for car plateno and some other controls

on cmbCustomernmae leave iam settign datasource for cmbPlateno as all plateno for that customer from database.

im using vb.net 2008 mssql 2005 windows app. code is as below:

VB
 Private Sub cmbCustomerName_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbCustomerName.Leave
    
'Code for fill datatable -removed here for easy reading
    cmbPlateNo.ValueMember = "car_id"
            cmbPlateNo.DisplayMember = "plate_no"
         cmbPlateNo.DataSource = dt
            cmbPlateNo.SelectedIndex = -1
end sub


the problem is behind the scenes it fills cmbplateno with each row of dt and setting text and then finally it makes selectedIndex as -1

As i have lot of functions related to this it shows each value on cmbplateno ..am id oing it right or is their anyother way of doing this.
plz help
Posted
Updated 1-Jun-13 5:03am
v2

try this
VB
Private Sub cmbCustomerName_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbCustomerName.Leave
    
'Code for fill datatable -removed here for easy reading
    cmbPlateNo.ValueMember = "car_id"
            cmbPlateNo.DisplayMember = "plate_no"
         cmbPlateNo.DataSource = dt.Tables(0) 'you forgot this
            cmbPlateNo.SelectedIndex = -1
end sub
 
Share this answer
 
cmbPlateNo.DataSource = dt

I havent forgot that. I have already written it and Im using datatable not dataset
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900