没有AutoPostBack = True的CheckBox CheckedChanged事件

问题描述 投票:0回答:1

我动态地将复选框控件添加到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,因为它使用默认值重新加载整个网格。

enter image description here

c# asp.net checkbox vb.net-2010 server-side-validation
1个回答
0
投票

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

`<`asp:UpdatePanel ID="itemPanel" runat="server" UpdateMode="Conditional"`>`<br/>
                `<`ContentTemplate`>`<br/>
                   //your controls<br/>
               `<`/ContentTemplate`>`<br/>
`<`/asp:UpdatePanel`>`
© www.soinside.com 2019 - 2024. All rights reserved.