datagrid on a panel that has visibility set to false

J

James

Man this is annoying. I have a datagrid on a panel. The panel has
..Visible=False. I did not specify the datagrid's visible property.

Now it seems that everytime I make any change to the datagrid, it
automatically sets the visible property to false. In Property Explorer, it
will not let me select anything but False. It displays both "True" and
False" on the dropdown, but if I click True, it keeps False. Nor will it
let me delete the value out (to make it blank).

Then, when I (in my code, reacting to events) set the panel to visible, the
datagrid is not visible. If I go into the HTML code and either delete the
visible property or explicitly set it True, it works fine.... until the very
next time I manipulate the datagrid with the GUI controls (such as Property
Builder). This means everytime I want to test a change, I must MANUALLY go
into the HTML code and delete the visible property that it is inserting in
there without me wanting it to. Is this a known issue? Is there some
setting I can set to stop it from automatically setting this property??

Thanks,

James
 
J

Jacob Yang [MSFT]

Hi James,

Based on my research and experience, it is a behavior by design.

While we change the visible property on a parent control to false, the
visible property of all the children inside that parent control will be set
to false as well.

Each time when we change the visible property on the parent control back to
true, we should iterate all its children to change the visible property to
true manually.

I hope it helps.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

James

On my system it doesn't quite work that way and I think it would be a little
unintuitive if it did.

If I have a panel that contains 20 other controls and I set the panel's
visible property to false, it does not change the contained controls at all
(except for datagrids). Once I set the panel's visibility back to True, the
20 controls appear. If I had to iterate amoung the 20 controls setting them
all back to visible, why would I use the panel in the first place?

The datagrid is the only control I have this problem with and I use panels
extensively throughout my applications. If I place a dropdown box (for
example) in a panel and then set the panel's visible property to false, it
does not affect the dropdown's visible property. I don't think it should be
doing it to the datagrid's visible property either. In some pages, I may
have 20 locations where the visibility of the panel is affected. Why would
I need to include an extra line of code to set the datagrid's visible
property but not the other 15 controls on the panel? It doesn't seem to
make much sense.

Thanks,

James
 
J

Jacob Yang [MSFT]

Hi James,

Thank you for your update.

Would you please tell me the version of your Visual Studio .NET? I think
that you are using VS.NET 2002. Is it correct?

My previous reply was based on my test on VS.NET 2002. Today I made the
same test on the vs.net 2003 edition, it seems that the behavior now is ok.
That is, when we set the visible on the panel object to false, the visible
properties of all its sub controls will also be changed to false, and vice
versa.

It seems that the behavior has been changed since vs.net 2003. In the
previous edition, we have to manually set the visible property on the
datagrid each time the visible property on the panel object was changed.
Please let me know if it makes sense.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

James

Sorry for the long delay in answering this question.

I am using VS 2003
Microsoft Development Environment 2003 Version 7.1.3088
Microsoft .NET Framework 1.1 Version 1.1.4322
 
J

Jacob Yang [MSFT]

Hi James,

Firstly, I want to reclaim what your concern is. You have a panel, which
contains a datagrid. When you set the visible property of the panel to
false, the visible property of the datagrid will also be set to false.
However, when you set the visible property of the panel back to true, the
visible property of the datagrid will not be set back to true. If I
misunderstood you, please let me know.

However, the test result on my side is different. When I set the visible
property of the panel back to true, the visible property of the contained
datagrid will also be set back to true. I also used VS.NET 2003. here are
the steps.

1. Create a new web application. Webform1.aspx was added by default.
2. Drag a panel onto the web form and then drag a datagrid into the panel.
3. Drag a button onto any space out of the panel
4. Paste the following code into the code-behind class.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not IsPostBack Then
' Load this data only once.
DataGrid1.DataSource = CreateDataSource()
DataGrid1.DataBind()
End If

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
'Session("customerID") = ddlCustomerID.SelectedItem.Text
'Response.Redirect("next.aspx")

If Panel1.Visible = False Then
Panel1.Visible = True
Else
Panel1.Visible = False
End If
End Sub

Function CreateDataSource() As ICollection
Dim dt As New DataTable
Dim dr As DataRow

dt.Columns.Add(New DataColumn("IntegerValue", GetType(Int32)))
dt.Columns.Add(New DataColumn("StringValue", GetType(String)))
dt.Columns.Add(New DataColumn("CurrencyValue", GetType(Double)))

Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()

dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 1.23 * (i + 1)

dt.Rows.Add(dr)
Next i

Dim dv As New DataView(dt)
Return dv
End Function 'CreateDataSource

Please help to test the code above on your side and let me know the result.

If I have misunderstood your concern, please feel free to let me know.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top