Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
im using vb lang. and database as oracle

i have a table which hav two rows .
i need to load one row as text and other as value .

my code is given below


VB
Private Sub GetAllTemp()

       Try
           conn.Open()
           Dim sql As String = "SELECT T_Name, Sno FROM UPLOADTEMPLATE"
           Dim cmd As New OracleCommand(sql, conn)
           cmd.CommandType = CommandType.Text
           Dim oraDataAdapter1 As New OracleDataAdapter
           oraDataAdapter1.SelectCommand = cmd
           Dim dtuser As New DataTable
           oraDataAdapter1.Fill(dtuser)
           cbTemplate.DataSource = dtuser
           cbTemplate.DisplayMember = "T_Name"
           'cbTemplate.ValueMember = "Sno"
           conn.Close()


       Catch ex As Exception

       End Try

   End Sub



VB
Private Sub cbTemplate_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbTemplate.SelectedIndexChanged


       MsgBox(cbTemplate.SelectedValue.ToString)

   End Sub




on loading values to combobox the code automatically triggers index change.
Posted
Updated 20-Jul-14 22:56pm
v2
Comments
nilesh sawardekar 21-Jul-14 6:20am    
error?
Suvendu Shekhar Giri 3-Jan-15 15:51pm    
Try placing a breakpoint in the GetAllTemp() method and debug. Carefully watch where the control moves after you filled the combobox.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900