none
Datatable or Excell Like Table for Variables RRS feed

  • Question

  • I would like to create a simple table with 3 colomns and 50 rows. And I would also like to know how I would output a variable to a cell. Thanks.
    Thursday, March 27, 2008 12:28 AM

Answers

  • You can do this with either a DataSet or with a DataTable

     

    Code Snippet

    public static DataTable dt = new DataTable("TableName");

     

    string[] ColName = new string[3];

    ColName[0] = "ID";

    ColName[1] = "Data";

    ColName[2] = "Data2";

     

    for (int i = 0; i < 3; i++)

    {

    DataColumn dc = new DataColumn();

    dc.ColumnName = ColName[i];

    dt.Columns.Add(dc);

    }

     

    Do this for every row of data

     

    DataRow dr = dt.NewRow();

    dr["ID"] = "";

    dr["Data"] = "";

    dr["Data2"] = "";

    dt.Rows.Add(dr);

     

     

     

     

     

    Thursday, March 27, 2008 12:57 AM