ASP.NET/VB: changing visibilty of panel inside formview

I have a panel inside a formview that is supposed to become visible when a checkbox (also inside the formview) is checked. I am able to access the controls, but I'm not sure how to actually make it work. This is my codebehind so far, I know it's not right, but it gives a basic idea of what I'm trying to do.

Protected Sub FormView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles FormView1.DataBound
    If FormView1.CurrentMode = FormViewMode.Edit Then

        Dim checkGenEd As CheckBox = FormView1.FindControl("checkGenEd")
        Dim panelOutcome As Panel = FormView1.FindControl("panelOutcome")

        If checkGenEd.Checked = True Then
            panelOutcome.Visible = True
        Else
            panelOutcome.Visible = False
        End If

    End If
End Sub

Answers


The question is a bit unclear but if you want mean when you check / uncheck the checkbox, then you need to use OnCheckChanged event of your checkbox like:

    <asp:TemplateField>
    <ItemTemplate>
        <asp:CheckBox ID="checkGenEd" AutoPostBack="true" Checked='<%# Eval("YourDBField") %>' OnCheckedChanged="checkGenEd_CheckedChanged" runat="server" />            
    </ItemTemplate>
    </asp:TemplateField> 

    Protected Sub checkGenEd_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs)
            Dim checkGenEd As CheckBox = DirectCast(sender, CheckBox)
            Dim panelOutcome As Panel = FormView1.FindControl("panelOutcome")

            If checkGenEd.Checked = True Then
                panelOutcome.Visible = True
            Else
                panelOutcome.Visible = False
           End If
End Sub

Need Your Help

Element-wise string comparison

python string comparison element

I need a fast function for element-wise comparison of two strings. Example:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.