How to add new DataRow into DataTable?

后端 未结 8 1263
我在风中等你
我在风中等你 2021-02-02 06:48

I have a DataGridView binded to a DataTable (DataTable binded to database). I need to add a DataRow to the DataTable

相关标签:
8条回答
  • 2021-02-02 07:22

    //َCreating a new row with the structure of the table:

    DataTable table = new DataTable();
    DataRow row = table.NewRow();
    table.Rows.Add(row);
    

    //Giving values to the columns of the row(this row is supposed to have 28 columns):

    for (int i = 0; i < 28; i++)
    {
        row[i] = i.ToString();
    }
    
    0 讨论(0)
  • 2021-02-02 07:23

    try table.Rows.add(row); after your for statement.

    0 讨论(0)
提交回复
热议问题