Using AutoGenerateColumns to generate Datagrid columns

Discussion in 'ASP .Net Web Controls' started by Amrut Kale, Sep 29, 2003.

  1. Amrut Kale

    Amrut Kale Guest

    I have an arraylist which contains FlightDetails objects

    public class FlightDetails {
    public string flightId;
    public string airline;
    public string fromCity;
    public string toCity;
    public System.DateTime date;
    public int numSeatsAvailable;
    public System.Double ticketFare;
    }

    When I try to use the the DataGrid as follows:


    flights = new ArrayList()

    /* code to populate the flighs arraylist - it just creates
    a set of new FlightDetails objects and adds them into
    the
    array */

    datagrid.DataSource = flights;
    datagrid.Databind();

    When the call to databind happens, it generates an error
    saying that DataGrid with id 'flights' could not
    automatically generate any columns from the selected data
    source.

    Is it possible to use the datagrid to automatically
    generate the columns using the above structure without
    having to convert the arraylist into a DataSet? If so
    how ?

    If not, what would be the best way to display the above
    structure so that I won't have to change the display code
    if I add or remove a few fields in future.

    regards, amrut.
    Amrut Kale, Sep 29, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim Mitchell

    Can you hide columns generated with AutoGenerateColumns?

    Jim Mitchell, Jul 17, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    158
    Jim Mitchell
    Jul 17, 2003
  2. AutoGenerateColumns on some columns

    , Jun 14, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    131
  3. Arthur Dent

    AutogenerateColumns and Static columns.

    Arthur Dent, Jun 22, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    162
    Arthur Dent
    Jun 22, 2005
  4. Tim_Mac

    styling Columns when using AutoGenerateColumns

    Tim_Mac, Oct 3, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    4
    Views:
    848
    Tim_Mac
    Nov 9, 2006
  5. Jerad Rose

    Hiding DataGrid Columns when AutoGenerateColumns="true"

    Jerad Rose, Mar 13, 2007, in forum: ASP .Net Datagrid Control
    Replies:
    7
    Views:
    968
    Jerad Rose
    Mar 14, 2007
Loading...

Share This Page