add new row in gridview after binding C#, ASP.net

前端 未结 5 1072
攒了一身酷
攒了一身酷 2020-12-09 04:26

\"enter

I want to add a new blank row to the gridview after binding as seen in the pic

5条回答
  •  忘掉有多难
    2020-12-09 04:55

    try using the cloning technique.

    {
        DataGridViewRow row = (DataGridViewRow)yourdatagrid.Rows[0].Clone();
        // then for each of the values use a loop like below.
        int cc = yourdatagrid.Columns.Count;
        for (int i2 = 0; i < cc; i2++)
        {
            row.Cells[i].Value = yourdatagrid.Rows[0].Cells[i].Value;
        }
        yourdatagrid.Rows.Add(row);
        i++;
        }
    }
    

    This should work. I'm not sure about how the binding works though. Hopefully it won't prevent this from working.

提交回复
热议问题