views:

45

answers:

0
    DataTable myTable = new DataTable("components");
    DataColumn mydatcolumn;

    mydatcolumn = new DataColumn();
    mydatcolumn.DataType = System.Type.GetType("System.String");
    mydatcolumn.ColumnName = "Component";

    myTable.Columns.Add(mydatcolumn);

    mydatcolumn = new DataColumn();
    mydatcolumn.DataType = System.Type.GetType("System.String");
    mydatcolumn.ColumnName = "Service Category";

    myTable.Columns.Add(mydatcolumn);

    mydatcolumn = new DataColumn();
    mydatcolumn.DataType = System.Type.GetType("System.String");
    mydatcolumn.ColumnName = "Component Owner";

    myTable.Columns.Add(mydatcolumn);


    for (int i = 0; i < serviceList.Count; i++)
    {
        DataRow mydatarow;
        //DataRow mydatarow2;
        mydatarow = myTable.NewRow();
        mydatarow["component"] = ComponentList[i];
        //mydatarow2 = myTable.NewRow();
        mydatarow["Service Category"] = sc[i];
        myTable.Rows.Add(mydatarow);
    }
    componentRGOdataGridView.DataSource = myTable;    

private void addCoButton_Click(object sender, EventArgs e)
{

}

As mention above, I am creating a DataTable with three columns and displaying the items in the 2 List<> (not shown above) on the datagridview using this dataTable. List populate rows for only 2 columns and the third column is for user input. On that button click event I want to write only those row in a file where user is giving input and ignore rest of the rows. How can I achieve this. Many Thanks