ArrayList and datagrid

Discussion in 'ASP .Net Datagrid Control' started by Steph, Apr 8, 2004.

  1. Steph

    Steph Guest

    Hello,

    I have a problem to bind my arrayList to a datagrid. I have read the article
    on MSDN but I dont ' understand where is the bug.

    I have 2 classes : DataTableUser and DataFieldUser. One field's type of
    DataTableUser is an ArrayList of DataFieldUser; others type are string.

    I have one ArrayList with some DataTableUser in.

    I bind this arrayList to a datagrid, no problem. So I want now rename Header
    Text and try this following code :

    ....

    DataGridTextBoxColumn cs;
    DataGridTableStyle ts = new DataGridTableStyle();
    ts.MappingName = typeof(ArrayList).Name;


    cs = new DataGridTextBoxColumn();
    cs.MappingName = "nameDataTableUser";
    cs.HeaderText = "name";
    cs.Width = 150;
    ts.GridColumnStyles.Add(cs);

    cs = new DataGridTextBoxColumn();
    cs.MappingName = "typeDataTableUser";
    cs.HeaderText = "type";
    cs.Width = 150;
    ts.GridColumnStyles.Add(cs);

    cs = new DataGridTextBoxColumn();
    cs.MappingName = "infoDataTableUser";
    cs.HeaderText = "Info";
    cs.Width = 150;
    ts.GridColumnStyles.Add(cs);

    // Add the custom tablestyle to the DataGrid
    dataGrid1.TableStyles.Clear();
    dataGrid1.TableStyles.Add(ts);

    ....

    At this time, it's ok, but :
    "type" has a + on the datagrid (because it is an ArrayList) and when I click
    on it I have a "System.IvalidOperationException".

    What can I do ?

    Thanks for your help
     
    Steph, Apr 8, 2004
    #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. Saravanan Rathinavelu

    Iterate through ArrayList using an another ArrayList

    Saravanan Rathinavelu, Aug 16, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    2,794
    Natty Gur
    Aug 19, 2003
  2. Kaidi
    Replies:
    4
    Views:
    2,484
    Kaidi
    Jan 3, 2004
  3. xz
    Replies:
    16
    Views:
    2,441
  4. Philipp
    Replies:
    6
    Views:
    968
    Arne Vajhøj
    May 28, 2008
  5. rp
    Replies:
    0
    Views:
    211
Loading...

Share This Page