Whats up all
I am attempting to populate a listbox from a dataset. This is what I am trying to do:
The above is not working. I was told that to populate the listbox I need add the following:
listBox1.DataSource = ds2.Tables("application)
lstBox1.DataTextField = "text"
listbox1.datavaluefield = "name"
listbox1.DataBind()
I recieve the error, "DataTextField not a member of System.windows.forms.listbox". The same happens for datavaluefield and databind. I am pretty new to this stuff so I am sure that I am missing something. All help is very much appreciated. Thanks.
I am attempting to populate a listbox from a dataset. This is what I am trying to do:
VB.NET:
Dim query2 As String = "Select i.name From asset_apps a, identification i Where a.appid=i.applicationid and a.asset= '" & lblAsset.Text & "'"
Dim ds2 As DataSet = New DataSet
Dim da2 As SqlDataAdapter = New SqlDataAdapter(query2, cnxn)
da2.Fill(ds2, "application")
Dim dv2 As DataView = New DataView(ds2.Tables("application"))
ListBox1.DataBindings.Add("text", dv2, "name")
The above is not working. I was told that to populate the listbox I need add the following:
listBox1.DataSource = ds2.Tables("application)
lstBox1.DataTextField = "text"
listbox1.datavaluefield = "name"
listbox1.DataBind()
I recieve the error, "DataTextField not a member of System.windows.forms.listbox". The same happens for datavaluefield and databind. I am pretty new to this stuff so I am sure that I am missing something. All help is very much appreciated. Thanks.