Click here to Skip to main content
12,404,478 members (73,263 online)
Rate this:
Please Sign up or sign in to vote.
See more: VB 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 9:39am

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

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