在DataGrid的模板列中置入了checkbox,程序中能够检测到checkbox,但是在checkbox被选中的情况下,检测到checkbox.checked=false,为什么?
我别的模块中也这样弄,但是能够检测到。

解决方案 »

  1.   

    出现这种情况,一般是你的页面Page_Load()处理DataGrid绑定没有放到if(!Page.IsPostBack)里面,也就是状态被你刷没了,,只是猜测....
      

  2.   

    拌定数据是否有放在if(!IsPostBack)中呢??很可能是这个问题导致..
      

  3.   

    Dim dtGItem As DataGridItem
            Dim i As Int32
            i = 0
            '定义一个checkbox,然后遍历控件
            Dim checkbox2 As CheckBox
            '定义一个标签,取得当前的书的id
            If DGBooks.Items.Count <> 0 Then
                     For Each dtGItem In DGBooks.Items
                    '下面的CheckBox1 就是列里面checkbox的id
                    If CType(dtGItem.FindControl("CheckBox1"), CheckBox).Checked = True Then
                        i = i + 1
    end ifResponse.write(i.tostring)
    //i<>0