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

[Solved] RadGrid Checkbox Conversion problem

3 Answers 133 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nicole Griesmeyer
Top achievements
Rank 1
Nicole Griesmeyer asked on 30 Sep 2009, 08:41 PM
Hello,

I would like a textbox column in my RadGrid. Unfortunately, I must have a boolean data type to get this to work, and what I have now is a char of 1 length (Y and N values). I looked into the sql conversion tables and couldn't find a compatible conversion. Is there a way to get the boxes to check or uncheck based on Y and N values, or a way to convert to boolean that I've missed?

I hope this question is clear, and appreciate any help.

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 01 Oct 2009, 06:54 AM
Hello Nicole,

I guess the field value returns Y or N and you want to set the CheckBox status accordingly. If so you could use a CheckBox in ItemTemplate of GridTemplateColumn as shown below.

aspx:
 
<telerik:GridTemplateColumn> 
    <ItemTemplate> 
        <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Convert.ToString(Eval("MartalStatus"))== "Y" ? true: false %>' /> 
    </ItemTemplate> 
</telerik:GridTemplateColumn> 

Hope this help,
Shinu.
0
Nicole Griesmeyer
Top achievements
Rank 1
answered on 05 Oct 2009, 04:36 PM
Thank you so much for your fast and helpful reply. I have two quick follow-up questions.

Your code worked perfectly. One error in the database, though, is that some of the values are actually lowercase y. Is there some sort of an "or" statement that could work here?

Also, I don't want them to be editable unless in edit mode. How do I specify this?

Thanks again, you are very helpful.

-Nicole
0
Shinu
Top achievements
Rank 2
answered on 08 Oct 2009, 12:57 PM
Hi Nicole,

Try with the following code.

ASPX:
 
<telerik:GridTemplateColumn UniqueName="CopyEmail" Display="false" HeaderText="Copy?"
    <ItemTemplate> 
    <asp:CheckBox ID="CheckBox1" runat="server" Enabled="false" Checked='<%# Convert.ToString(Eval("MartalStatus")).ToLower() == "y" ? true: false %>' />  
    </ItemTemplate> 
    <EditItemTemplate> 
        <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Convert.ToString(Eval("MartalStatus")).ToLower() == "y" ? true: false %>' />  
    </EditItemTemplate> 
</telerik:GridTemplateColumn> 

-Shinu.
Tags
Grid
Asked by
Nicole Griesmeyer
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Nicole Griesmeyer
Top achievements
Rank 1
Share this question
or