简体   繁体   中英

How to get Devexpress LookupEdit Value Member Value?

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

要获取选定的值,您可以简单地执行txtSupplier.EditValue

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM