我想要在dataGridView1_CellContentClick_2这个事件中,修改dataGridView表中一条记录中的一个数据。并把修改过的数据保存的数据库中,那在这个单击事件中应该怎么写。
我的dataGridView是:
第一行的第一列是一个超链接,第二列是一个数(每点一次前面的超链接,该数就加1)
第二行同理===========================
我的代码:
 private void dataGridView1_CellContentClick_2(object sender, DataGridViewCellEventArgs e)
        {
            string wz = dataGridView1.CurrentRow.Cells[2].Value.ToString();            System.Diagnostics.Process.Start("http://" + wz);
           此处在怎样写呢,才能把它后面列的数累加呢?
         }

解决方案 »

  1.   

                string wz = dataGridView1.CurrentRow.Cells[2].Value.ToString();             System.Diagnostics.Process.Start("http://" + wz);            int intWz = 1;
                //判断wz是否是数值,若是数值intWz = Convert.ToInt32(wz) + 1;            dataGridView1.CurrentRow.Cells[2].Value = intWz;            //执行数据库操作
      

  2.   

     在
    System.Diagnostics.Process.Start("http://" + wz); 
    之前执行累加
      

  3.   

     private void dataGridView1_CellContentClick_2(object sender, DataGridViewCellEventArgs e) 
            { 
                string wz = dataGridView1.CurrentRow.Cells[0].Value.ToString();             System.Diagnostics.Process.Start("http://" + wz);            int count = Convert.ToInt32(this.dataGridView1.CurrentRow.Cells[1].Value) + 1;
                this.dataGridView1.CurrentRow.Cells[1].Value = (object)count;
                //后面更新数据库自己写吧
            }
      

  4.   


    private void dataGridView1_CellContentClick_2(object sender, DataGridViewCellEventArgs e) 
            { 
                dataGridView1.EndEdit();
                string wz = dataGridView1.CurrentRow.Cells[2].Value.ToString();             System.Diagnostics.Process.Start("http://" + wz); 
              //此处在怎样写呢,才能把它后面列的数累加呢? 
                int num=dataGridView1.CurrentRow.Cells[数字列索引].FormatValue.ToString();
              num+=1;
              dataGridView1.CurrentRow.Cells[数字列索引].value=num;
            }