This is a migrated thread and some comments may be shown as answers.

Get GridViewCheckBoxColumn selected on grid

3 Answers 118 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Flávio
Top achievements
Rank 1
Flávio asked on 08 Sep 2011, 09:16 PM
Hi,

   I'd like know how to do get value of rows selected with CheckBox on GridView?
Example:

Name               |  Selected
Steve Jobs        
Bill Gates                x
Larry Page
Mark Zuck               x

Your select Bill Gates and Mark Zuck.

I tried with foreach, but isn't get the values selected.

Thanks attention!

3 Answers, 1 is accepted

Sort by
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 09 Sep 2011, 05:34 AM
Hello Flavio,

You can use the following:
var checkedRows = radGridView1.Rows.Where(r => r.Cells[2].Value != null && r.Cells[2].Value is bool && (bool)r.Cells[2].Value);

where 2 is the index for the column, or you can use the name of the column directly.

Hope this helps, if you have any other questions please let me know,

Best Regards,
Emanuel Varga

WinForms MVP
0
Flávio
Top achievements
Rank 1
answered on 09 Sep 2011, 05:54 PM
Hi Emanuel,

   I tried implent your code in my application, but isn't worked. Occured a error when I set radGridView1.Rows.Where(...), where isn't exist.
Do you have any tip what can be?

Image with message error attached!

Thanks attention!
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 09 Sep 2011, 06:15 PM
Hello

Just add using System.Linq; to the references if you are using .net 3.5, if not, let me know and i'll reformat the code.

Best regards,
Emanuel Varga
Tags
GridView
Asked by
Flávio
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Flávio
Top achievements
Rank 1
Share this question
or