How to add a column to a DataTable

Discussion in 'ASP .Net' started by ad, Jun 6, 2005.

  1. ad

    ad Guest

    I want to add a Column to a DataTable.
    I use the codes below;
    I want the Column dc to be a type of Boolean.
    How can I assign the DataType?

    ----------------------------------------------------------------------------
    --------
    DataTable dt = aDataSet.Tables[0];
    DataColumn dc = new DataColumn();
    dc.DataType=??
     
    ad, Jun 6, 2005
    #1
    1. Advertising

  2. ad

    Derek Harmon Guest

    "ad" <> wrote in message news:...
    >I want to add a Column to a DataTable.
    > I use the codes below;
    > I want the Column dc to be a type of Boolean.
    > How can I assign the DataType?


    dc.DataType = typeof( bool);
    dt.Columns.Add( dc);

    Derek Harmon
     
    Derek Harmon, Jun 6, 2005
    #2
    1. Advertising

  3. ad

    Amar Guest

    dc.DataType = System.Type.GetType("System.Boolean");

    "ad" <> wrote in message news:<>...
    > I want to add a Column to a DataTable.
    > I use the codes below;
    > I want the Column dc to be a type of Boolean.
    > How can I assign the DataType?
    >
    > ----------------------------------------------------------------------------
    > --------
    > DataTable dt = aDataSet.Tables[0];
    > DataColumn dc = new DataColumn();
    > dc.DataType=??
     
    Amar, Jun 6, 2005
    #3
    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. J. Babe
    Replies:
    1
    Views:
    8,432
    Kevin Spencer
    Aug 15, 2003
  2. jg
    Replies:
    1
    Views:
    758
    =?Utf-8?B?U2hhaWxlc2ggSmFubnU=?=
    Aug 17, 2004
  3. Ersin Gençtürk
    Replies:
    1
    Views:
    3,557
    Ersin Gençtürk
    Oct 6, 2004
  4. gbattine
    Replies:
    0
    Views:
    684
    gbattine
    Sep 4, 2006
  5. GoodMorningSky

    How to add New Column to existing DataTable in specific position.

    GoodMorningSky, Oct 5, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    4
    Views:
    1,353
    Alex Homer
    Oct 6, 2004
Loading...

Share This Page