Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide User Control

Status
Not open for further replies.

Peppi

Programmer
Apr 9, 2001
205
CA
Hi,

I have a user control which contains a GridView. The user control is supposed to hide/show depending on whether or not there is any data in the GridView. In the GridView RowDataBound event, I do the following:

Code:
If e.Row.RowType = DataControlRowType.DataRow Then
  'Do stuff
ElseIf e.Row.RowType = DataControlRowType.Footer Then
  'Do more stuff.
  [b]Me.Visible = True[/b]
ElseIf e.Row.RowType = DataControlRowType.EmptyDataRow Then
  [b]Me.Visible = False[/b]
End If

This code does not work in that the Me.Visible = True line is not being performed. I have set a breakpoint on that line and after the line executes, Me.Visible is still False. How can that be? Is it getting confused with the parent page or something? Not sure what's going on here.
Yes, ShowFooter is set to true and this line of code IS executing, just not changing the property value. I've tried to use a panel and just showing/hiding that, but the exact same thing happens.
 
try this in the Page.Load event
Code:
//bind gridview to datasource.
me.Visislbe = Not (myGridView.Rows.Count = 0)

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Did you trace through the code? It could be that the visible line does get exectued but then the me.visible = false also gets executed because there is an emptydatarow in the gridview.
 
I have stepped through the code. The line Me.Visible = True is not setting it to True. I've checked the value of Me.Visible immediately after the line executes, and it is still set to False. Very strange. Can't be a read-only property or it would give me a message.
 
I've figured out the problem. I had the user controls contained within a panel along with some other controls in my main page and was hiding or showing the panel depending on whether or not any of the user controls were visible. So when I tried to execute Me.Visible = True on my user control, it wasn't working because the parent panel was set to invisible.

One issue down...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top