没有AutoPostBack = True的CheckBox CheckedChanged事件

时间:2017-05-17 13:41:34

标签: c# asp.net checkbox vb.net-2010 server-side-validation

我动态地将复选框控件添加到GridView列。 在每个GridView_RowBound()事件上,复选框被添加到列中。 还定义了RowBound()事件中的CheckBox_CheckedChanged事件,如下所示,

Protected Sub GridviewChildItem_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)

    If e.Row.RowType = DataControlRowType.DataRow AndAlso Not String.IsNullOrEmpty(CRMSignCond) Then
        Dim lbValue As Label = DirectCast(e.Row.Cells(5).FindControl("lbValue"), Label)
        e.Row.Cells(5).Attributes.Add("onmousemove", "Show('" + lbValue.Text + "')")
        e.Row.Cells(5).Attributes.Add("onmouseout", "this.style.backgroundColor=this.oldcolor;Hide();")
    End If

    AddTemplateControls(Nothing, e)


End Sub
Private Sub AddTemplateControls(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)
    Dim cbTargetSign As New CheckBox
    Dim rbConsolidate As New RadioButtonList
    Dim tbSignGrp As New TextBox

    cbTargetSign.ID = "chkSelect"
    cbTargetSign.AutoPostBack = False
    cbTargetSign.Checked = True
    rbConsolidate.ID = "rbConsolidate"
    tbSignGrp.ID = "tbSigningGroup"
    tbSignGrp.Width = 25
    If Not e.Row.RowIndex = -1 Then
        e.Row.Cells(6).Controls.Add(cbTargetSign)
        e.Row.Cells(4).Controls.Add(tbSignGrp)
        e.Row.Cells(7).Controls.Add(rbConsolidate)
    End If
    rbConsolidate.RepeatDirection = RepeatDirection.Horizontal
    rbConsolidate.Items.Add("Yes")
    rbConsolidate.Items.Add("No")
    rbConsolidate.Items(1).Selected = CBool(True)
    If cbTargetSign.Checked Then
        rbConsolidate.Enabled = False
    End If
    **AddHandler cbTargetSign.CheckedChanged, AddressOf cbTargetSign_CheckedChanged**
End Sub

' Checkbox- CheckedChanged事件。

Public Sub cbTargetSign_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)

End Sub

每当我选中网格中的复选框时,checkedChanged事件都不会触发。有人指导我如何解决这个问题吗?

注意:我不想将AutoPostBack复选框设置为TRUE,因为它会使用默认值重新加载整个网格。

FileUtils.copyDirectoryToDirectory(...)

1 个答案:

答案 0 :(得分:0)

如果您不想将AutoPostBack复选框设置为TRUE,因为它会使用默认值重新加载整个网格,您将尝试设置AutoPostBack="True"并且:

`<`asp:UpdatePanel ID="itemPanel" runat="server" UpdateMode="Conditional"`>`<br/>
                `<`ContentTemplate`>`<br/>
                   //your controls<br/>
               `<`/ContentTemplate`>`<br/>
`<`/asp:UpdatePanel`>`