对不起更正一下,在datalist的模板列中放的是一个HtmlInputCheckBox。

解决方案 »

  1.   

    你要对CheckBox进行转换,如果是Checked,那么就把该CheckBox对应的数据1或0保存到数据库中,除非你使用的是true,false,否则自己要转换一下的。HtmlInputCheckBox可以让他运行在服务器端。
      

  2.   

    问题是,我在程序中设断点,当走到判断HtmlInputCheckBox控件的checked属性时,它总是跳到true部分去执行。可明明是false呀。
      

  3.   

    这一段是datalist的itemdatabund事件中为chk2写的一段客户端代码:(控制其它控件的可操作性)
    chk2.Attributes("onclick") = "javascript: " & _
                                            " if (" & chk2.ClientID & ".checked) " & _
                                            "    { " & Bgtime.ClientID & ".disabled = false;" & _
                                                       Edtime.ClientID & ".disabled = false;" & _
                                                       Vbtime.ClientID & ".enabled = true; " & _
                                                       Vetime.ClientID & ".enabled = true; " & _
                                            "    } " & _
                                            " else " & _
                                            "    { " & Bgtime.ClientID & ".disabled = true;" & _
                                                       Edtime.ClientID & ".disabled = true;" & _
                                                       Vbtime.ClientID & ".enabled = false; " & _
                                                       Vetime.ClientID & ".enabled = false; " & _
                                            "    } "
    这一段是向数据库中添数据的,要判断chk2的状态:
    Dim chk2 As HtmlInputCheckBox = CType(DL.Items(index).FindControl("checkbox" & dlnum & "_2"), HtmlInputCheckBox)
                    If Not chk2 Is Nothing Then
                        'Response.Write(bid & " " & chk2.Checked.ToString() & " " & chk2.Checked & "<br>")
                        If chk2.Checked = False Then
                            oRow.Item("TimeLimit") = 0
                            oRow.Item("TimeBegin") = DateTime.Now
                            oRow.Item("TimeEnd") = DateTime.Now
                        Else
                            oRow.Item("TimeLimit") = 1
                            Dim txt4 As TextBox = CType(DL.Items(index).FindControl("Textbox" & dlnum & "_2"), TextBox)
                            If Not txt4 Is Nothing And txt4.Text <> "" Then
                                oRow.Item("TimeBegin") = txt4.Text
                            Else
                                oRow.Item("TimeBegin") = DateTime.Now
                            End If
                            Dim txt5 As TextBox = CType(DL.Items(index).FindControl("Textbox" & dlnum & "_3"), TextBox)
                            If Not txt5 Is Nothing And txt5.Text <> "" Then
                                oRow.Item("TimeEnd") = txt5.Text
                            Else
                                oRow.Item("TimeEnd") = DateTime.Now
                            End If
                        End If
                    End If