Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Set/Get checkbox value in Gridview

Posted on 2007-11-22
4
Medium Priority
?
6,963 Views
Last Modified: 2010-04-21
Hi all,

Hopefully a quick one, I have a normal Gridview with normal text columns but with one holding a checkbox for an "attended" field.  

What I'm after is that when this checkbox is ticked, on CheckedChanged event I want to update the database to say the course has been attended if the Checkbox is checked.

I can access the CheckedChanged event fine from within the Gridview, but I would like the checkbox to hold the ID of the course, so I can then automatically use a "Update tbl where ID = CHECKBOXVALUE".

I can only set the bound ID to either the Text or Checked parts of the Checkbox though, so the value is appearing alongside the Checkbox in the Gridview, which I don't want to be visable, is there a way to attach the value so I can use it but no have it display next to the checkbox?

Cheers
0
Comment
Question by:MiddlesbroughPCT
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 10

Accepted Solution

by:
Oliver Amaya earned 260 total points
ID: 20336003
Hi, what I usually do is have a label control along side it, assigned with the ID I need, and set it as not visible, if you can determined in which the checkbox is situated you can use FindControl to get the label.
0
 
LVL 10

Expert Comment

by:Oliver Amaya
ID: 20336009
Meant to say in which row of the GridView the checkbox is situated.
0
 

Assisted Solution

by:lonekawboy
lonekawboy earned 240 total points
ID: 20336954
Use the DataKeys variable from the GridView to hold the key pieces of data for the grid. Then on events you can pull the values once you have the RowIndex for the GridViewRow i.e. gvResult.DataKeys[ gvrRow.RowIndex ][ "ID" ].
0
 
LVL 1

Author Closing Comment

by:MiddlesbroughPCT
ID: 31410583
Both answers apply so split points, thanks for answering.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question