Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > I am trying to hide some textboxes, dropdownlists and labels in datalist

Reply
Thread Tools

I am trying to hide some textboxes, dropdownlists and labels in datalist

 
 
Dgreer
Guest
Posts: n/a
 
      08-31-2006
I am trying to hide some textboxes, dropdownlists and labels in
datalist.

I have some textboxes, dropdownlists and labels in a table in a
datalist how do I hide them after they're bound?

Here is some of my code in the datalist.ItemDataBound Event.

Select Case editvisiblity

Case 1
Dim txt As New TextBox
txt = CType(e.Item.FindControl("etxtPK_User_ID"),
TextBox)
txt.Visible = False
e.Item.FindControl("etxtLastLogin").Visible = False
e.Item.FindControl("etxtCreatedBy").Visible = False
e.Item.FindControl("etxtCreationDate").Visible =
False
e.Item.FindControl("ddlRole").Visible = False
e.Item.FindControl("etxtLocID").Visible = False
e.Item.FindControl("ddlUserLevel").Visible = False
e.Item.FindControl("echkActive").Visible = False
e.Item.FindControl("etxtConfirmPassword").Visible =
False
e.Item.FindControl("etxtPassword").Visible = False
e.Item.FindControl("etxtCofilter").Visible = False

e.Item.FindControl("txtPK_User_ID").Visible = False
e.Item.FindControl("txtLastLogin").Visible = False
e.Item.FindControl("txtCreatedBy").Visible = False
e.Item.FindControl("txtCreationDate").Visible =
False
e.Item.FindControl("ddlRole").Visible = False
e.Item.FindControl("txtLocID").Visible = False
e.Item.FindControl("txtPassword").Visible = False
e.Item.FindControl("ddlUserLevel").Visible = False
e.Item.FindControl("chkActive").Visible = False
e.Item.FindControl("txtConfirmPassword").Visible =
False
e.Item.FindControl("txtCofilter").Visible = False

Case 2
e.Item.FindControl("txtCreatedBy").Visible = False
e.Item.FindControl("txtCreationDate").Visible =
False
e.Item.FindControl("txtLocID").Visible = False

e.Item.FindControl("etxtCreatedBy").Visible = False
e.Item.FindControl("etxtCreationDate").Visible =
False
e.Item.FindControl("etxtLocID").Visible = False
End Select
End If

 
Reply With Quote
 
 
 
 
offwhite@gmail.com
Guest
Posts: n/a
 
      09-01-2006
Have you walked through it with the debugger yet?

At a glance I do not see any reason why it would not be setting the
visibility as you want. And if possible, simply place the controls you
want to hide in a Panel and just set the Visible flag on the panel.

Also, I noticed that in your code you are assuming your controls are
always going to be found. If you do change the ID value ever this code
will break badly.

What I normally do for this code is create a useful private method...

Private Sub SetVisibility(ByVal parentControl as Control, ByVal name as
String, ByVal isVisible as bool)

Dim control as Control = parentControl.FindControl(name)
If control IsNot Nothing
control.Visible = isVisible
Else
-- Log or complain that the control was not found
End If

End Sub

You could when call it this way...

SetVisibility(e.Item, "etxtCreationDate", True)

In your log you may see that for some reason it is not finding your
controls.


Brennan Stehling
http://brennan.offwhite.net/blog/


Dgreer wrote:
> I am trying to hide some textboxes, dropdownlists and labels in
> datalist.
>
> I have some textboxes, dropdownlists and labels in a table in a
> datalist how do I hide them after they're bound?
>
> Here is some of my code in the datalist.ItemDataBound Event.
>
> Select Case editvisiblity
>
> Case 1
> Dim txt As New TextBox
> txt = CType(e.Item.FindControl("etxtPK_User_ID"),
> TextBox)
> txt.Visible = False
> e.Item.FindControl("etxtLastLogin").Visible = False
> e.Item.FindControl("etxtCreatedBy").Visible = False
> e.Item.FindControl("etxtCreationDate").Visible =
> False
> e.Item.FindControl("ddlRole").Visible = False
> e.Item.FindControl("etxtLocID").Visible = False
> e.Item.FindControl("ddlUserLevel").Visible = False
> e.Item.FindControl("echkActive").Visible = False
> e.Item.FindControl("etxtConfirmPassword").Visible =
> False
> e.Item.FindControl("etxtPassword").Visible = False
> e.Item.FindControl("etxtCofilter").Visible = False
>
> e.Item.FindControl("txtPK_User_ID").Visible = False
> e.Item.FindControl("txtLastLogin").Visible = False
> e.Item.FindControl("txtCreatedBy").Visible = False
> e.Item.FindControl("txtCreationDate").Visible =
> False
> e.Item.FindControl("ddlRole").Visible = False
> e.Item.FindControl("txtLocID").Visible = False
> e.Item.FindControl("txtPassword").Visible = False
> e.Item.FindControl("ddlUserLevel").Visible = False
> e.Item.FindControl("chkActive").Visible = False
> e.Item.FindControl("txtConfirmPassword").Visible =
> False
> e.Item.FindControl("txtCofilter").Visible = False
>
> Case 2
> e.Item.FindControl("txtCreatedBy").Visible = False
> e.Item.FindControl("txtCreationDate").Visible =
> False
> e.Item.FindControl("txtLocID").Visible = False
>
> e.Item.FindControl("etxtCreatedBy").Visible = False
> e.Item.FindControl("etxtCreationDate").Visible =
> False
> e.Item.FindControl("etxtLocID").Visible = False
> End Select
> End If


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"pointlabel"-like function for Python: distribute text labels on a2-d scatter plot to avoid overlapping labels C Barrington-Leigh Python 1 09-12-2010 09:58 PM
Setting SelectedValue for nested DropDownLists in DataList Crazy Cat ASP .Net 2 09-10-2007 03:55 PM
Accessing dropdownlists in a datalist control =?Utf-8?B?TWlrZSBE?= ASP .Net 1 08-15-2007 03:00 PM
CheckBox Outside DataList & Labels Inside DataList rn5a@rediffmail.com ASP .Net 1 12-24-2006 02:28 PM
Setting up a datalist control - Item_DataBound for a datalist in a datalist Nevyn Twyll ASP .Net 8 09-09-2004 10:13 PM



Advertisments