取得Gridview的指定某一列的值

原文链接:https://blog.csdn.net/di0808/article/details/101887620

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;
            }
        }

posted @ 2025-12-05 18:13  yinghualeihenmei  阅读(0)  评论(0)    收藏  举报