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

Getting GridViewCheckBoxColumn value

5 Answers 181 Views
GridView
This is a migrated thread and some comments may be shown as answers.
DenisCL
Top achievements
Rank 1
DenisCL asked on 29 Apr 2011, 03:38 PM
Hello,

I would like to access a specific checkbox value in my grid.
After some hours of searching the correct syntax and way to do it, I come to you for more information.

For example, how can I get the myGrid.row[2].cell["checkbox"] value (where the cell is checkbox) outside of any events?
Actually can cast something somewhere in the cell GridViewCellInfo to get the inner checkbox value?

Thanks

regards

5 Answers, 1 is accepted

Sort by
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 29 Apr 2011, 03:44 PM
Hello Denis,

You are correct, you can get the cell value like that, for example:
 bool value = false;
 if (radGridView1.Rows[0].Cells["Checkbox"].Value != null)
 {
     value = (bool)radGridView1.Rows[0].Cells["Checkbox"].Value;
 }

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

Best Regards,
Emanuel Varga

Telerik WinForms MVP
0
DenisCL
Top achievements
Rank 1
answered on 03 May 2011, 08:45 AM
Hello

Thanks for this little code, but I finally fall on what i'm stuck

The value is empty. When I try to cast it, i have an exception (see picture attached)

That's why I was talking about an inner value of the checkbox in the gridviewcheckboxcolumn.

Where is the checkbox value?

regards
0
Emanuel Varga
Top achievements
Rank 1
answered on 03 May 2011, 08:56 AM
Hello again,

What do you mean by empty? If it's null it should not enter there and if it's not null it has to be a bool... Could you provide a small sample for this case?

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

Best Regards,
Emanuel Varga

Telerik WinForms MVP
0
DenisCL
Top achievements
Rank 1
answered on 03 May 2011, 02:10 PM
Hello,

My bad I didn' t notice when the checkbox state is false, it's in fact system.DBNull.

It's ok now.

the value is true when checked
0
Emanuel Varga
Top achievements
Rank 1
answered on 03 May 2011, 06:59 PM

Glad to be able to help,

If you have any more questions please just let me know, and if the question has been solved, please mark the question as answered, so that others can find the answers to their questions faster.

Best Regards,
Emanuel Varga


WinForms MVP
Tags
GridView
Asked by
DenisCL
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
DenisCL
Top achievements
Rank 1
Share this question
or