Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
Hi All,
 
I have a combo box in my form. I loaded my combo box with values from the data table as follows:
m_dtDelayedDeliveryDays = GetDelayedDeliveryDays()
 

 
       For Each dr As DataRow In m_dtDelayedDeliveryDays.Rows
           Me.cmbDelayedDeliveryDays.Items.Add(dr("DeliveryDelayDays"))
       Next
 
       cmbDelayedDeliveryDays.DataSource = m_dtDelayedDeliveryDays
       cmbDelayedDeliveryDays.DisplayMember = "DeliveryDelayDays"
       cmbDelayedDeliveryDays.ValueMember = "DeliveryDelayDaysID"
       cmbDelayedDeliveryDays.SelectedIndex = -1
 
And i load the selected value's ID into the database table as follows:
 
If cmbDelayedDeliveryDays.SelectedIndex > 0 Then
           Dim delayId As Integer
           Dim selectedDataRow As DataRow = DirectCast(cmbDelayedDeliveryDays.SelectedItem, DataRowView).Row
           delayId = Convert.ToInt32(selectedDataRow("DeliveryDelayDaysID"))
 
       End If
 
Till this it works fine. Now when i try to retrieve the form it should display the selected value in the combo box.
 
I have my already selected value's ID in the m_objUIMgr.DeliveryDelayDaysID property. How do i assign the value of the ID to the combo box.Please help.
 
My table looks like this
ID Days
1 0
2 3
Posted 20-Feb-13 10:39am
vidkaat534

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

  Print Answers RSS
0 DamithSL 295
1 OriginalGriff 214
2 BillWoodruff 170
3 Zoltán Zörgő 165
4 Maciej Los 113
0 OriginalGriff 7,760
1 DamithSL 5,874
2 Sergey Alexandrovich Kryukov 5,444
3 Maciej Los 5,076
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web03 | 2.8.141223.1 | Last Updated 20 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100