Geeks With Blogs

News My Blog has been MOVED to https://mfreidge.wordpress.com
Michael Freidgeim's OLD Blog My Blog has been MOVED to https://mfreidge.wordpress.com

In one of ASP.NET pages I've used CheckBox column inside Datagrid, and  on some condition the column containing checkbox was invisible 
TemplateColumn.Visible=false
On postback my code tried to read if  control is checked, and it always returned  chk.Checked=false.

It seems that it is done by design and  invisible CheckBox does not have ViewState["Checked"].


As it suggested in the link Invisible column won't be rendered to the client.(http://www.velocityreviews.com/forums/t93577)-aspnet-datagrid-template-column-when-inivisible.html):

Make the column invisible with css rule display:none.

Posted on Wednesday, October 11, 2006 11:06 AM ASP.NET | Back to top


Comments on this post: ASP.NET CheckBox inside Datagrid returns Checked=false in Postback, if the column is not visible.

# re: ASP.NET CheckBox inside Datagrid returns Checked=false in Postback, if the column is not visible.
Requesting Gravatar...
I have just come across this very annoying problem myself. Did you find an easy solution to it?
Left by Cedd Burge on May 30, 2007 4:02 AM

# re: ASP.NET CheckBox inside Datagrid returns Checked=false in Postback, if the column is not visible.
Requesting Gravatar...
As it suggested in the link http://www.velocityreviews.com/forums/t93577-aspnet-datagrid-template-column-when-inivisible.html

Make the column invisible with css rule display:none.
Left by Michael Freidgeim on May 30, 2007 12:10 PM

# re: ASP.NET CheckBox inside Datagrid returns Checked=false in Postback, if the column is not visible.
Requesting Gravatar...
My code is like this.. it say check box checked is false.

----------

Protected Sub CheckNow(ByVal sender As Object, ByVal e As System.EventArgs) Handles button2.Click
recipient_list.Text = ""
Dim I As Long
For I = 0 To friends.Items.Count - 1
Dim CurrentCheckBox As CheckBox
CurrentCheckBox = friends.Items(I).FindControl("ChkSelect")
'recipient_list.Text & = friends.Items(I).ItemIndex & CurrentCheckBox.text.ToString() & "-" & CurrentCheckBox.checked.ToString() & "<br>"
recipient_list.Text & = CurrentCheckBox.text.ToString() & "-" & CurrentCheckBox.Checked.ToString()

Next
End Sub
Left by I have the same problem on Nov 14, 2007 6:11 AM

# re: ASP.NET CheckBox inside Datagrid returns Checked=false in Postback, if the column is not visible.
Requesting Gravatar...
Hey, that was interesting,

I had the same problem but couldn't figure out the problem. but with the diplay none everthing is solved.

Thanks for writing about it
Left by web development company on Aug 14, 2009 7:06 AM

Your comment:
 (will show your gravatar)


Copyright © Michael Freidgeim | Powered by: GeeksWithBlogs.net