locked
How a ListBox is populated from a data table? RRS feed

  • Question

  • How a List Box is populated from a data table?
    Friday, February 25, 2011 12:34 PM

Answers

  • Is this not a standard C# question?

    // in reality your DataTable would be populated from somewhere?
    DataTable myDataTable = new DataTable();
    
    ListBox myListBox = new ListBox();
    
    // apply data source and bind it
    myListBox.DataSource = myDataTable;
    myListBox.DataBind();
    
    

    regards
    Martin Hatch
    MCPD SharePoint 2010 | .Net Web Development
    MCTS WSS 3.0 | MOSS 2007
    Visit my Blog - www.martinhatch.com
    • Proposed as answer by Phill Duffy Friday, February 25, 2011 3:07 PM
    • Marked as answer by Wayne Fan Tuesday, March 1, 2011 2:49 AM
    Friday, February 25, 2011 12:58 PM

All replies

  • Is this not a standard C# question?

    // in reality your DataTable would be populated from somewhere?
    DataTable myDataTable = new DataTable();
    
    ListBox myListBox = new ListBox();
    
    // apply data source and bind it
    myListBox.DataSource = myDataTable;
    myListBox.DataBind();
    
    

    regards
    Martin Hatch
    MCPD SharePoint 2010 | .Net Web Development
    MCTS WSS 3.0 | MOSS 2007
    Visit my Blog - www.martinhatch.com
    • Proposed as answer by Phill Duffy Friday, February 25, 2011 3:07 PM
    • Marked as answer by Wayne Fan Tuesday, March 1, 2011 2:49 AM
    Friday, February 25, 2011 12:58 PM
  • Thank you very much...
    Tuesday, March 1, 2011 6:01 AM