Solved

Set/Get checkbox value in Gridview

Posted on 2007-11-22
4
6,956 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 65 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 60 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

635 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