Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • I have a LookUpEdit control that I populate using the following code:

                                            Dim myDB As New DBAccess

                                    If myDB.Connect(RISData.Instance.ProjectDB) = False Then
                                                Exit Sub
                                            Else
                                                Dim myDA As New SqlClient.SqlDataAdapter("spQryStatus", myDB.myConn)
                                                myDA.SelectCommand.CommandType = CommandType.StoredProcedure
                                                Dim myDS As New DataSet("ReviewStatus")
                                                myDA.Fill(myDS, "ReviewStatus")

                                    Me.cmbStatus.Properties.DataSource = New BindingSource(myDS, "ReviewStatus")
                                                Me.cmbStatus.Properties.DisplayMember = "statusName"
                                                Me.cmbStatus.Properties.NullText = ""
                                                Me.cmbStatus.Properties.ValueMember = "ID"

                                    Me.cmbStatus.Properties.DropDownRows = myDS.Tables("ReviewStatus").Rows.Count

                                    myDA.Dispose()
                                                myDS.Dispose()

                                    'Me.cmbStatus.Properties.PopupWidth = Me.cmbStatus.Properties.Columns(1).Width
                                            End If

                                    What I want to do is loop through the LookUpEdit control and return the ValueMember for each row in the dropdown.

                                    Thanks

                                    Simon

                                • It's probably easiest to just get a reference to the DataTable the LookUpEdit is bound to.

                                  DataTable statusDataSource = cmbStatus.Properties.DataSource as DataTable;

                                  foreach(DataRow statusRow in statusDataSource.Rows)
                                  {
                                       int StatusID = Convert.ToInt32(statusRow["ID"]);
                                  }

                                1 Solution

                                Creation Date Rating Importance Sort by
                                -1

                                The easiest way to accomplish this task is to traverse directly through your datasource rows as Brendon suggested:

                                [C#]
                                DataTable statusDataSource = cmbStatus.Properties.DataSource as DataTable; foreach(DataRow statusRow in statusDataSource.Rows) { int StatusID = Convert.ToInt32(statusRow["ID"]); } Processed, T
                                • Michael Leppan 07.22.2015

                                  DataSource as DataTable = null, so this method doesn't work.

                                • Andrew Ser (DevExpress Support) 07.22.2015

                                  Hello,
                                  This may happen if your LookUpEdit is not bound to a DataTable. Cast the LookUpEdit's data source to your data source type (for example, List<MyClass>) and change the class instance property manually.

                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, ASP.NET, WinForms, HTML5 or Windows 10, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2015 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners