日期:2014-05-18  浏览次数:20784 次

DATAGRIDVIEW中CHECKBOX选后行的值相加问题
C# code

        private void NOPAY_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            double c = 0;
            if (e.ColumnIndex == 0)
            {
                for (int i = 0; i < this.NOPAY.RowCount; i++)
                {
                    if (this.NOPAY.Rows[i].Cells[0].Value.ToString () == "1")
                    {
                        c += double.Parse(this.NOPAY[4, i].Value.ToString());
                        this.label5.Text = c.ToString();
                    }
                }
            }
        }



第一列是CHECKBOX,想点一下CHECKBOX,将第四列的值相加.提示if (this.NOPAY.Rows[i].Cells[0].Value.ToString () == "1")
这句有错,具体要什么搞啊,请高手帮帮我

------解决方案--------------------
C# code
for (int i = 0; i <= gvlistdetailauChoix.Rows.Count - 1; i++)
            {
                CheckBox cbox = (CheckBox)gvlistdetailauChoix.Rows[i].FindControl("cbNumerolist");
                if (cbox.Checked == true)
                {
                    listnumero.Add(gvlistdetailauChoix.Rows[i].Cells[1].Text);
                    listnom.Add(gvlistdetailauChoix.Rows[i].Cells[2].Text);
                }

            }