how to get value of checkboxes in datagrid

Posted on 2009-05-24
Medium Priority
Last Modified: 2012-05-07
hi All
hav a good day

i have a window form
on this form i hav a datagrid view. i hav add a checkbox column and three bounded columns productname,price and quantity.
These three columns are filled in datagridview from database.
This checkbox column is for select the products.
supose gridview has 6 products and at the run time user select 4 products by clicking on checkboxes.
 then i want to get all three values (product name,price,quantity) for these four products  for which checkbox column is checked.

Any help will be appriciated.
Thanks in Advance.
Question by:psaini172000
  • 2
  • 2

Accepted Solution

HarryNS earned 400 total points
ID: 24464940
LVL 22

Assisted Solution

by:Ivo Stoykov
Ivo Stoykov earned 600 total points
ID: 24464990
below is a small sample
StringBuilder str = new StringBuilder();
// Select the checkboxes from the GridView control
for (int i = 0; i < GridView1.Rows.Count; i++)
  GridViewRow row = GridView1.Rows[i];
  bool isChecked = ((CheckBox) row.FindControl("chkSelect")).Checked;
  if (isChecked)
    // Column 2 is the name column
// prints out the result

Open in new window


Author Comment

ID: 24466069
My problem is not on webapplication
it is on windows application. Thats why ur solution dont work

Thanks for this help

Author Comment

ID: 24466075
if Any Body hav any idea pls help
LVL 22

Assisted Solution

by:Ivo Stoykov
Ivo Stoykov earned 600 total points
ID: 24470534

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…
In the video, one can understand the process of resizing images in single or bulk. Kernel Bulk Image Resizer is an easy to use tool for resizing large number of images. One can add and resize multiple images with this tool in single go. The video sh…

624 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