怎样把多个textbox数据 添加到datagrid里对应的列面,可以添加多行数据。这数据只是暂时保存在datagrid点保存的时候再把datagrid的多行添加的数据提交到数据库?
谁能给我个详细的例子啊、、!!!

解决方案 »

  1.   

    string[] str = { "你要插入的数据1", "你要插入的数据2", "你要插入的数据3"};  
    dataGridView1.Rows.Add(str);
      

  2.   

    同意楼上的,用Row.add,添加一行记录、、
      

  3.   

    int sum=0;
    for(int i=0;i<datagridview.rows.count;i++){
        sum+=int.Parse(rows[i].Cells["需要求和的那列列名"].Value.toString());
    }
      

  4.   

    对每列的话 把Cells["需要求和的那列列名"] 换成 Cells[i]
      

  5.   

    DataGridView1.Rows.Add("", "1行2列", "1行3列", "1行4列", "1行5列");   DataGridViewRow row = new DataGridViewRow();   
    row.Cells[0].Value ="";
    row.Cells[1].Value ="";
    this.dataGridView1.Rows.Add(row);
    public void TotalRow(DataGridView dg)
      {
      dg.Rows.Add();
      DataGridViewRow dgr = dg.Rows[dg.Rows.Count - 1];
      dgr.ReadOnly = true;
      dgr.DefaultCellStyle.BackColor = System.Drawing.Color.Khaki;
      dgr.Cells[0].Value = "合计";
      for (int i = 0; i < dg.Rows.Count - 1; i++)
      {
      dgr.Cells[3].Value = Convert.ToSingle(dgr.Cells[3].Value) + Convert.ToSingle(dg.Rows[i].Cells[3].Value);
      }
      }