Click here to Skip to main content
11,480,626 members (62,929 online)
Rate this: bad
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
       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

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 294
1 OriginalGriff 190
2 CPallini 150
3 Richard MacCutchan 150
4 CHill60 130
0 Sergey Alexandrovich Kryukov 8,184
1 OriginalGriff 7,556
2 Sascha Lefèvre 3,114
3 Maciej Los 2,491
4 Richard Deeming 2,335

Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 20 Feb 2013
Copyright © CodeProject, 1999-2015
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