By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,816 Members | 2,151 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,816 IT Pros & Developers. It's quick & easy.

CheckBox Outside DataList & Labels Inside DataList

P: n/a
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 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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
rn**@rediffmail.com 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 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.