c# - How to display table values to listbox? -


How do I display a table value in the CatalogBox control? With this code I got the ProjectCode value from TeamMember_table:

  SqlDataAdapter adp = New SqlDataAdapter ("Select ProjectCode from TeamMember_table where EmpId = '" + eid + "' '' , Who);  

I want to display this ProjectCode value in the list box .

Platform: Visual Studio 2008, C # with ASP.NET.

Using ASP.NET ListBox control, you can do it by declaring a DataSource property:

  ListBox1.DataSource = YourDataSource; ListBox1.DataTextField = "projectCode"; ListBox1.DataBind ();  

Where "YourDataSource" can be datable with data from your SqlDataAdapter.

You can also manually add each item:

  list item = new list item (); Item.Text "sometext" =; Item.Value "somevalue" =; ListBox1.Items.Add (item);  

You can read more about data binding and ASP.NET list box control.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -