Click here to Skip to main content
15,888,113 members
Home / Discussions / C#
   

C#

 
GeneralRe: how to use a list array to populate a listbox with columns Pin
robertkjr3d26-Mar-09 7:57
robertkjr3d26-Mar-09 7:57 
GeneralRe: how to use a list array to populate a listbox with columns Pin
dan!sh 26-Mar-09 8:15
professional dan!sh 26-Mar-09 8:15 
GeneralRe: how to use a list array to populate a listbox with columns Pin
robertkjr3d26-Mar-09 8:25
robertkjr3d26-Mar-09 8:25 
GeneralRe: how to use a list array to populate a listbox with columns Pin
Fayu26-Mar-09 8:39
Fayu26-Mar-09 8:39 
GeneralRe: how to use a list array to populate a listbox with columns Pin
dan!sh 26-Mar-09 8:48
professional dan!sh 26-Mar-09 8:48 
AnswerRe: how to use a list array to populate a listbox with columns Pin
Fayu26-Mar-09 8:00
Fayu26-Mar-09 8:00 
GeneralRe: how to use a list array to populate a listbox with columns Pin
robertkjr3d26-Mar-09 8:08
robertkjr3d26-Mar-09 8:08 
GeneralRe: how to use a list array to populate a listbox with columns Pin
Fayu26-Mar-09 8:37
Fayu26-Mar-09 8:37 
The DataSource accepts more than just a DataSet or DataTable. The DataSource property accepts anything that implements IListSource, IEnumerable....

Below is what I tried and it worked for me. Try again.

public class Customer
{
    public Customer(string name, int id)
    {
        this.name = name;
        this.id = id;
    }

    private string name;
    public string Name
    {
        get { return name; }
        set { name = value; }
    }

    private int id;
    public int Id
    {
        get { return id; }
        set { id = value; }
    }

}

protected void Page_Load(object sender, EventArgs e)
{
    List<Customer> customer = new List<Customer>();
    customer.Add(new Customer("John", 1));
    customer.Add(new Customer("Mike", 2));
    customer.Add(new Customer("Freddy", 3));

    this.ListBox1.DataSource = customer;
    this.ListBox1.DataTextField = "Name";
    this.ListBox1.DataValueField = "Id";

    this.DataBind();
}

GeneralRe: how to use a list array to populate a listbox with columns Pin
robertkjr3d26-Mar-09 8:43
robertkjr3d26-Mar-09 8:43 
GeneralRe: how to use a list array to populate a listbox with columns Pin
Henry Minute26-Mar-09 10:39
Henry Minute26-Mar-09 10:39 
QuestionEmbed a progress bar inside a treeview node Pin
JamieNS26-Mar-09 7:30
JamieNS26-Mar-09 7:30 
AnswerRe: Embed a progress bar inside a treeview node Pin
dan!sh 26-Mar-09 7:55
professional dan!sh 26-Mar-09 7:55 
QuestionArgument Exception appears in some computers but not in others Pin
VitroBlue26-Mar-09 7:15
VitroBlue26-Mar-09 7:15 
AnswerRe: Argument Exception appears in some computers but not in others Pin
Luc Pattyn26-Mar-09 8:44
sitebuilderLuc Pattyn26-Mar-09 8:44 
QuestionSend data to USB ? Pin
Mohammad Dayyan26-Mar-09 7:00
Mohammad Dayyan26-Mar-09 7:00 
AnswerRe: Send data to USB ? Pin
Giorgi Dalakishvili26-Mar-09 7:31
mentorGiorgi Dalakishvili26-Mar-09 7:31 
AnswerRe: Send data to USB ? Pin
Luc Pattyn26-Mar-09 7:31
sitebuilderLuc Pattyn26-Mar-09 7:31 
GeneralRe: Send data to USB ? Pin
Mohammad Dayyan26-Mar-09 7:56
Mohammad Dayyan26-Mar-09 7:56 
GeneralRe: Send data to USB ? Pin
Luc Pattyn26-Mar-09 8:04
sitebuilderLuc Pattyn26-Mar-09 8:04 
AnswerRe: Send data to USB ? Pin
Yusuf26-Mar-09 7:46
Yusuf26-Mar-09 7:46 
QuestionLINQ results flatten Pin
ywang55526-Mar-09 6:57
ywang55526-Mar-09 6:57 
AnswerRe: LINQ results flatten Pin
Henry Minute26-Mar-09 10:42
Henry Minute26-Mar-09 10:42 
QuestionPossible to run postback-code before Page_load-code? Pin
sa}{en26-Mar-09 6:10
sa}{en26-Mar-09 6:10 
AnswerRe: Possible to run postback-code before Page_load-code? Pin
Henry Minute26-Mar-09 6:34
Henry Minute26-Mar-09 6:34 
AnswerRe: Possible to run postback-code before Page_load-code? Pin
EliottA26-Mar-09 6:35
EliottA26-Mar-09 6:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.