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

[Solved] How to implement Binded checkbox column

3 Answers 130 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Timothy
Top achievements
Rank 1
Timothy asked on 29 Oct 2010, 01:54 AM
How do you implement a checkboxcolumn to be checked if Binded value is 1, and unchecked if binded value is 0.

I have no problem getting the data into the table but this is what it looks like,

Hostname        IsChecked
TestName        1
TestName2      1
TestName3      0

Instead of the 1 or 0, I want a check box (checked if 1, unchecked if 0)

I am new to this so please help.

Thanks,
Tim 

3 Answers, 1 is accepted

Sort by
0
Accepted
Maya
Telerik team
answered on 29 Oct 2010, 07:28 AM
Hi Timothy,

You may create an IValueConverter that gets the int-value and converts it to boolean. Afterwards, all you need to do is to define the GridViewCheckBoxColumn and bind it to the converted value. I am sending you a sample project illustrating the proposed solution.

Greetings,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Timothy
Top achievements
Rank 1
answered on 29 Oct 2010, 08:37 AM
You know how they always say Men will drive around for hours before asking for directions. Well I drove around for two days trying to figure this out.

Maya, thank you very much for the quick response. I took a look at the project you provided and I see now how you implemented the converter within the XAML.

I tested this out in my project and it worked perfectly. I have read a ton of your postings here and I must say Telrik is lucky to have you on their staff. Your technical prowess is outstanding.

I do have one question. Is there any way to flag my SQL table column type appropriately so I can avoid having to do the conversion in code? Currentl it is set to Int.

Thanks again!

Tim
0
Maya
Telerik team
answered on 29 Oct 2010, 04:17 PM
Hi Timothy,

There is no problem to achieve that functionality in the data level by using the proper SELECT statement. You may either define a IF statement returning boolean on the required conditions or modify a  StoredProcedure so that it accomplishes the same goal. 

Regards,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Timothy
Top achievements
Rank 1
Answers by
Maya
Telerik team
Timothy
Top achievements
Rank 1
Share this question
or