Hi,
I have added the following code in the Combobox load event by binding datas from DB
Private Sub ComboBox1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.Load
Dim sql As String
Dim adapter As New SqlDataAdapter
Dim ds As New DataSet
Dim connection As SqlConnection = New SqlConnection("Server=pc1207;uid=sa;pwd=welcome3#;database=IRDB")
sql = "select * from tblSubmissiontypes"
Dim Command As SqlCommand = New SqlCommand
connection.Open()
Command = New SqlCommand(sql, connection)
ComboBox1.DataSource = Command.ExecuteReader
ComboBox1.DataValueField = "SubmissionTypeID"
ComboBox1.DataValueField = "SubmissionTypeName"
ComboBox1.DataBind()
connection.Close()
End Sub
SubmissionTypeID starts from 1,2,3... and the submissiontypename for Id 1 is Apple, 2 is Orange, 3 is Grapes for eg.
In combobox submissiontypename is displaying.
My doubt is when I click Apple, I must get the SubmissiontypeId of Apple i.e .1 in this example.
Can any one specify a code for that?
Thanks in advance.