Strange behavior of invisible controls

  • Thread starter Thread starter Peter Afonin
  • Start date Start date
P

Peter Afonin

Hello:

I'm updating multiple rows in the datagrid, using the routine described in
the article "Top Questions about the DataGrid Web Server Control":

http://msdn.microsoft.com/library/d...questionsaboutaspnetdatagridservercontrol.asp

To determine which rows had been changed, I'm using the RowChanged sub:

Protected Sub RowChanged(ByVal sender As Object, _
ByVal e As System.EventArgs)
'---------------------------------------------------------------------------
---------------------
' Add ID's for changed rows
'---------------------------------------------------------------------------
---------------------
Try
Dim dgi As DataGridItem = _
CType(CType(sender, Control).NamingContainer, DataGridItem)
Dim IDlabel As Label = CType(dgi.FindControl("lblOrder"), Label)
Dim ID As Integer = CType(IDlabel.Text, Integer)
If Not (IDlist.Contains(ID)) Then
IDlist.Add(ID)
End If
Catch ex As Exception
Me.lblError.Text = "Error No.: " & Err.Number.ToString & " - " & ex.ToString
End Try
End Sub

<asp:CheckBox id="chkInHouse" ToolTip="Plates In House" runat="server"
OnCheckedChanged="RowChanged" Checked='<%# DataBinder.Eval(Container,
"DataItem.InHouse") %>'>

It works OK everywhere, except one datagrid where some of my checkboxes are
invisible - the user has to click a button to make them visible. These
invisible checkboxes always indicate that their values had been changed. As
a result all my data from the datagrid is sent to the database, even if no
changes has been made. As soon as I make these checkboxes visible -
everything works OK.

Why is this happening? Is there any workaround?

I would appreciate your help.

Thank you,
 
Hi,

If you set checkbox visibility by visible property and you are using
postback to change visible state maybe there is something in the
postback activity that cause that behavior.

you can change check box visibility by changing visibility attribute of
control Style using javascrit thus reducing network traffic.

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
 
Thank you, Natty.

Do you have a JavaScript sample on how to do this? I don't know JS well.

Peter
 
Back
Top