dim litem as datagriditem
dim chex as boolean
for each litem in datagrid.items
    chex=ctype(litem.findcontrol("checkboxid"),check).checked
    if chec then
       .....
    end if
next

解决方案 »

  1.   

    把page_load中的绑定代码放在
    if(!IsPostBack)
    {
       // datagrid bind code
    }
    中,不然你每次执行事件前,datagrid被重新绑定,自然获取不了你的选定值了
      

  2.   

    我刚刚按你所说修改了代码如下
         Dim litem As DataGridItem
            Dim obj As CheckBox
            For Each litem In DataGrid1.Items
                
                obj = litem.Cells(5).FindControl("CheckBox1")
                If (obj.Checked) Then
                    Response.Write("sss")
                End If
            Next
    可是不行呀!我想我这么写跟你的意思应该是一样吧?因为按你的写总是调试不过去,这句话chex=ctype(litem.findcontrol("checkboxid"),check).checked  有错误,十分谢谢!!
      

  3.   

    Ctype(litem.FindControl("checkboxid"),CheckBox).checked  多思考
      

  4.   

    我想不是选中框的问题,你可以返回checkbox的ID看一下,如果有,你照我说的去试试,
      

  5.   

    在你最先的代码里面,取obj.ClientID试试
      

  6.   

    非常感谢以上所有帮助我的人,尤其是Cnapollo,按你说的我已有了启发。我希望有机会能交到象你们这样乐于帮助别人的人,希望我们以后共同努力!加油!!