当前位置:编程学习 > html/css >>

GridView获取带有复选框(CheckBox)的行信息

foreach (GridViewRow item in GridView1.Rows) { if (item.RowType != DataControlRowType.Header) { if ((item.FindControl("CheckBox1") as CheckBox).Checked) { Response.Write(item.Cells[1].Text); } } } foreach (GridViewRow item in GridView1.Rows) { if (item.RowType != DataControlRowType.Header) { if ((item.FindControl("CheckBox1") as CheckBox).Checked) { Response.Write(item.Cells[1].Text); } } }


用循环来判断GridView中的每一行中CheckBox是否被选中,如被选中则可获取改行第二列内容。

 

补充:web前端 , HTML/CSS  ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,