1

Hi Im using devexpress . I want to know how to get the value member value in lookupEdit. I set the DisplayMember as prior to SupplierName And ValueMember to SupplierID

The code below displays both and SupplierName as the text in lookupedit.. what I want is to keep the SupplierName as the Display but I want to get the supplierID when saving it to database

Scenario:

I want the value of the Supplier ID for example 001 - Supplier1 The display text in the look up is Supplier1 what I want is the 001

 Private Function LoadSupplierData()
    Dim bResult As Boolean
    Dim SQLcmd As New System.Text.StringBuilder
    SQLcmd.AppendLine("SELECT SupplierID,SupplierName ")
    SQLcmd.AppendLine("FROM Supplier ")
    SQLcmd.AppendLine("WHERE Status='Active'")
    Try
        Using SQLconnect As New SqlConnection(g_constring)
            Using SQLadapter As New SqlDataAdapter(SQLcmd.ToString, SQLconnect)
                Dim ds As New DataSet
                SQLadapter.Fill(ds, "SupplierDetails")
                Dim dvm As DataViewManager = New DataViewManager(ds)
                dvMain = dvm.CreateDataView(ds.Tables("SupplierDetails"))
            End Using
        End Using
        txtSupplier.Properties.DataSource = dvMain
     Catch ex As Exception
        MessageBox.Show(ex.Message.Trim, "Error in database", MessageBoxButtons.OK, MessageBoxIcon.Stop)
        bResult = False
    End Try
    Return bResult
End Function
Filip
  • 3,257
  • 2
  • 22
  • 38
Prince Jea
  • 5,524
  • 7
  • 28
  • 46
  • you want the value from the selected row in the lookup? – Ezi Feb 15 '12 at 04:46
  • no I want the value of the Supplier ID for example 001 - Supplier1 The display text in the look up is Supplier1 what I want is the 001.. is that possible? – Prince Jea Feb 15 '12 at 04:49
  • 1
    yes it's possible, if you set the ValueMember to SupplierID then this is how it is. – Ezi Feb 15 '12 at 04:52
  • Iv'e already set the value member to SupplierID but I cant get the value ..can you show me some code on how to get the value of the value member ? – Prince Jea Feb 15 '12 at 04:55

1 Answers1

5

To get the selected value you could simply do txtSupplier.EditValue

Ezi
  • 2,212
  • 8
  • 33
  • 60