现在的位置: 首页 > 综合 > 正文

从CodeBehind访问页面上的控件(2.0)

2012年08月29日 ⁄ 综合 ⁄ 共 405字 ⁄ 字号 评论关闭
和以前的用法有点不同,所以记录下来了。

ArrayList list = new ArrayList();
foreach (GridViewRow row in GridView1.Rows)
{
 CheckBox box = (CheckBox)row.Cells[3].Controls[1];
 if (box.Checked)
  list.Add(row.Cells[0].Text);
}
return list;

Dim list As ArrayList = New ArrayList()
For Each row As GridViewRow In GridView1.Rows
    Dim box As CheckBox = CType(row.Cells(3).Controls(1), CheckBox)
    If (box.Checked) Then
        list.Add(row.Cells(0).Text)
    End If
Next
Return list

抱歉!评论已关闭.