天天看點

取得Gridview的指定某一列的值

int sum = 0;

        for (int i = 0; i  < this.GridView1.Rows.Count; i++) 

        { 

            GridViewRow row=this.GridView1.Rows[i];

            sum=sum+Convert.ToInt32(row.Cells[21].Text.ToString());

        }

            Response.Write(sum.ToString());

還有一種方法:

BLL.newline bllnewline = new BLL.newline();

        foreach (GridViewRow gvr in gvnextshengchan.Rows)

        {

            CheckBox ch = (CheckBox)gvr.FindControl("CheckBox1");

            if (ch.Checked)

            {

                string proname = gvr.Cells[4].Text;

            }

        }

轉載于:https://www.cnblogs.com/J2EEPLUS/archive/2010/06/06/2487928.html