|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
vb.net 2005 - how to populate a listboxPlease direct me to a source which will explain how to populate a listbox
with retrievable values. For example, I would like to display the customer name from the customer table, but store the Customer ID which is available when an customer is selected from the listbox. Thanks Hi bill,
If you create a DataTable from your customer table with ID and Name in it you can set it as the DataSource of your list box, then set DisplayMember and ValueMember to the name and ID respectively. You then call the ListBox.SelectedValue in the postback. Steve. Show quoteHide quote "bill" <bel***@datamti.com> wrote in message news:u7LExL6ZGHA.1196@TK2MSFTNGP03.phx.gbl... > Please direct me to a source which will explain how to populate a listbox > with retrievable values. > > For example, I would like to display the customer name from the customer > table, but store the Customer ID which is available when an customer is > selected from the listbox. > > Thanks > > Thanks!
Show quoteHide quote "Steve Lloyd" <steve.rem***@livenowpaylater.this.co.uk> wrote in message news:uf$ZPQ6ZGHA.508@TK2MSFTNGP02.phx.gbl... > Hi bill, > > If you create a DataTable from your customer table with ID and Name in it > you can set it as the DataSource of your list box, then set DisplayMember > and ValueMember to the name and ID respectively. > > You then call the ListBox.SelectedValue in the postback. > > Steve. > > > "bill" <bel***@datamti.com> wrote in message > news:u7LExL6ZGHA.1196@TK2MSFTNGP03.phx.gbl... >> Please direct me to a source which will explain how to populate a listbox >> with retrievable values. >> >> For example, I would like to display the customer name from the customer >> table, but store the Customer ID which is available when an customer is >> selected from the listbox. >> >> Thanks >> >> > > Bill,
Dim dtIDA As New DataTable dtIDA.Columns.Add("IDA", GetType(System.String)) dtIDA.Columns.Add("Description") dtIDA.LoadDataRow(New Object() {"FQ", "Faqs"}, True) dtIDA.LoadDataRow(New Object() {"DX", "DirextX"}, True) dtIDA.LoadDataRow(New Object() {"LK", "Links"}, True) dtIDA.DefaultView.Sort = "Description" lstTitles.DataSource = dtIDA.DefaultView lstTitles.DisplayMember = "Description" lstTitles.ValueMember = "IDA" Do you mean something as above I hope this helps, Cor Show quoteHide quote "bill" <bel***@datamti.com> schreef in bericht news:u7LExL6ZGHA.1196@TK2MSFTNGP03.phx.gbl... > Please direct me to a source which will explain how to populate a listbox > with retrievable values. > > For example, I would like to display the customer name from the customer > table, but store the Customer ID which is available when an customer is > selected from the listbox. > > Thanks > > Thanks Cor.
Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:etkr9g6ZGHA.3880@TK2MSFTNGP04.phx.gbl... > Bill, > > Dim dtIDA As New DataTable > dtIDA.Columns.Add("IDA", GetType(System.String)) > dtIDA.Columns.Add("Description") > dtIDA.LoadDataRow(New Object() {"FQ", "Faqs"}, True) > dtIDA.LoadDataRow(New Object() {"DX", "DirextX"}, True) > dtIDA.LoadDataRow(New Object() {"LK", "Links"}, True) > dtIDA.DefaultView.Sort = "Description" > lstTitles.DataSource = dtIDA.DefaultView > lstTitles.DisplayMember = "Description" > lstTitles.ValueMember = "IDA" > > Do you mean something as above > > I hope this helps, > > Cor > > > "bill" <bel***@datamti.com> schreef in bericht > news:u7LExL6ZGHA.1196@TK2MSFTNGP03.phx.gbl... >> Please direct me to a source which will explain how to populate a listbox >> with retrievable values. >> >> For example, I would like to display the customer name from the customer >> table, but store the Customer ID which is available when an customer is >> selected from the listbox. >> >> Thanks >> >> > > "bill" <bel***@datamti.com> wrote in message The nice thing about the listbox is that the items property is just a news:u7LExL6ZGHA.1196@TK2MSFTNGP03.phx.gbl... > Please direct me to a source which will explain how to populate a listbox > with retrievable values. collection of objects. An ArrayList will do. When the listbox is rendered, it the Framework calls ToString() on each object. Each object could be your custom class with ID and CustomerName properties, or whatever you like. So while databinding also works fine, it is really very flexible. Tim How stable is Visual Studio 2005? http://www.itwriting.com/blog/?postid=414
Make font Bold
Iterate through page controls Register DLL for COM interop Performance testing tools for VB.NET application A couple of easy datagrid questions wav files in programs show form into splitcontainer.panel Disable auto browse window DEALING WITH NULL QUERY RESULTS COM reference (X) as Interop.X |
|||||||||||||||||||||||