CheckBox Outside DataList & Labels Inside DataList

Discussion in 'ASP .Net' started by rn5a@rediffmail.com, Dec 24, 2006.

  1. Guest

    A ASPX page has a DataList control with a few Labels. This page also
    has a CheckBox which resides OUTSIDE the DataList. By default, this
    CheckBox is checked. If the CheckBox is checked, then the Labels
    existing in the DataList should be visible but if the CheckBox is
    unchecked by the user, the Labels inside the DataList should be made
    invisible.

    How do I do this?

    Note that the AutoPostBack property of the CheckBox has been set to
    True so that as soon as the CheckBox is checked/unchecked by the user,
    the page gets posted & the Labels inside the DataList become
    visible/invisible respectively.
     
    , Dec 24, 2006
    #1
    1. Advertising

  2. Guest

    I figured it out; this is how I did it (just in case if someone else
    happens to come across this dilemma....on the CheckedChanged event of
    the CheckBox whose ID is "chk1"):

    Sub chk1_CheckChanged(ByVal obj As Object, ByVal ea As EventArgs)
    Dim dlItem As DataListItem

    For Each dlItem In DataList1.Items
    If (chk1.Checked) Then
    dlItem.FindControl("Label1").Visible = True
    dlItem.FindControl("Label2").Visible = True
    dlItem.FindControl("Label3").Visible = True
    Else
    dlItem.FindControl("Label1").Visible = False
    dlItem.FindControl("Label2").Visible = False
    dlItem.FindControl("Label3").Visible = False
    End If
    Next
    End Sub


    wrote:
    > A ASPX page has a DataList control with a few Labels. This page also
    > has a CheckBox which resides OUTSIDE the DataList. By default, this
    > CheckBox is checked. If the CheckBox is checked, then the Labels
    > existing in the DataList should be visible but if the CheckBox is
    > unchecked by the user, the Labels inside the DataList should be made
    > invisible.
    >
    > How do I do this?
    >
    > Note that the AutoPostBack property of the CheckBox has been set to
    > True so that as soon as the CheckBox is checked/unchecked by the user,
    > the page gets posted & the Labels inside the DataList become
    > visible/invisible respectively.
     
    , Dec 24, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bigtoga
    Replies:
    1
    Views:
    658
    Chee Seong Ong
    Apr 28, 2004
  2. Luis Esteban Valencia
    Replies:
    1
    Views:
    493
    John Saunders
    Jan 6, 2005
  3. =?Utf-8?B?RGVlcHNvbiBUaG9tYXM=?=

    Checkbox Labels accept keystrokes and show the characters????

    =?Utf-8?B?RGVlcHNvbiBUaG9tYXM=?=, May 22, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    322
    =?Utf-8?B?RGVlcHNvbiBUaG9tYXM=?=
    May 22, 2006
  4. JesperGJensen

    How to access Labels inside Repeater

    JesperGJensen, Feb 5, 2008, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    452
    Angel
    Feb 5, 2008
  5. Krzysztof Poc

    outside type, outside function

    Krzysztof Poc, Feb 3, 2012, in forum: C++
    Replies:
    1
    Views:
    288
    Victor Bazarov
    Feb 7, 2012
Loading...

Share This Page