General information
Title:
How do I add record to the combo box ?
Dear The Expert,
How do I add record to the combo box ? .. I wrote below codes for add record to the combobox and
then display them .. but it does not work .. am I missing something?
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim ds As DataSet = GetDataSet()
BindComboBox(ds)
End If
End Sub
Private Function GetDataSet() As DataSet
Dim mSQL As String
mSQL = "Select * from MyUserGroup Order by GroupID"
Dim con As New OleDbConnection(mConnectionString)
Dim cmd As New OleDbCommand(mSQL, con)
Dim adapter As New OleDbDataAdapter(cmd)
Dim dsGroup As New DataSet()
adapter.Fill(dsGroup, "UserGroup")
con.Close()
Return dsGroup
End Function
Private Sub BindComboBox(ByVal ds As DataSet)
ComboUserGroup.DataSource = ds.Tables("UserGroup")
Me.DataBind()
End Sub
TIA
Winan
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only