954,593 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Updating a checkbox within a template field in a gridview

Hi,

A bit of searching reveals that a few people have asked this question before, but I can never see the solution revealed.

I have a gridview and I've added a column with a template field so that I can put a checkbox control in it. Finding it is no problem, so I can determine if it's checked or unchecked. It's making it checked or unchecked using code that's got me scratching my head.

Here's the line that I've been trying to use in the vb file (which I know doesn't work). Perhaps it will show someone what I'm trying to do. Is there a simple solution here?
"Use" is the ID of my checkbox, but the intellisense shows me straight away that it doesn't understand "checked"; it doesn't know in this line that "Use" actually refers to a checkbox apparently. Any clues?

Gridview1.Rows(1).Cells(0).FindControl("Use").checked = True


Thanks very much in advance for any help.

Paradox 99
Newbie Poster
8 posts since Jul 2011
Reputation Points: 10
Solved Threads: 0
 

Hi,

Check out this article and see if it helps.
http://www.4guysfromrolla.com/articles/052406-1.aspx

catherine sea
Junior Poster
126 posts since Jan 2008
Reputation Points: 25
Solved Threads: 20
 

Hi,

Check out this article and see if it helps. http://www.4guysfromrolla.com/articles/052406-1.aspx

Thank you for the quick reply. I'll check it out.

Paradox 99
Newbie Poster
8 posts since Jul 2011
Reputation Points: 10
Solved Threads: 0
 

Excellent! Thank you, I found exactly what I needed there.
My code ended up as:

Dim Chb as Checkbox = CType(Arms.Rows(1).Cells(0).FindControl("Use"), CheckBox)
Chb.Checked = True
Paradox 99
Newbie Poster
8 posts since Jul 2011
Reputation Points: 10
Solved Threads: 0
 

Glad to hear it helps. :)

catherine sea
Junior Poster
126 posts since Jan 2008
Reputation Points: 25
Solved Threads: 20
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: