I\'m using a ListBox and adding objects to it.
The object contains 2 variables, let\'s say username and userid.
How can I add the objects in the list (like l
Set the DataTextField and DataValueField
DataTextField
DataValueField
ListBox a = new ListBox(); a.DataTextField = "username"; a.DataValueField = "userid";
To add using .Add method you can use:
.Add
a.Items.Add(new ListItem() { Value = User.ID, Text = User.Name });