首页 > 代码库 > GridView中根据CheckBox选中的行取出某列的值

GridView中根据CheckBox选中的行取出某列的值

根据CheckBox选中的行取出某列的值:

for (int i = 0; i < this.GridView1.Rows.Count; i++)
        {
            CheckBox ckb = (CheckBox)this.GridView1.Rows[i].Cells[0].FindControl("CheckBox1");
            if (ckb.Checked)
            {
                huohao =Convert.ToInt32(this.GridView1.Rows[i].Cells[2].Text);
                shuliang = Convert.ToInt32(this.GridView1.Rows[i].Cells[3].Text);
                danjia =Convert.ToDecimal(this.GridView1.Rows[i].Cells[4].Text);
                heJiJinE =Convert.ToDecimal(this.GridView1.Rows[i].Cells[5].Text);
                jinhuoId =Convert.ToInt32(this.GridView1.Rows[i].Cells[7].Text);
            }
        }