Skip to content

C#.net

suraj Bhoir

suraj Bhoir

Asked May 16, 2013, 1:17 AM EDT1 answer
Share
LinkedInX
How we can declar the data row

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Sandeep Singh Shekhawat
    0
    private void CreateNewDataRow()
    {

    // below to create a new table.
    DataTable table = new DataTable();

    //Add Columns to table

      table.Columns.Add("fName", typeof(string));
    table.Columns.Add("lName", typeof(string));

    // Once a table has been created, use the  

    // NewRow to create a DataRow.
    DataRow row; row = table.NewRow();

    // Then add the new row to the collection.
    row["fName"] = "John";
    row["lName"] = "Smith";

    table.Rows.Add(row);

    //now use table as data source
    }
    0