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

Setting default selection of a radcombobox in GridEditableItem

0 Answers 119 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 07 Jan 2011, 07:09 PM
I have a RadGrid that is using a FormTemplate when inserting/updating values.

One of the values in my SQL Table is a bit flag. That is, it's going to be either true or false.

I can easily set this bit using a checkbox like the following in my FormTemplate:

<asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Eval("CanBeFatal") != DBNull.Value ? Convert.ToBoolean(Eval("CanBeFatal")) : false %>' />

This essentially selects the checkbox if the flag is set to true. However, I would prefer to display a RadComboBox instead of a checkbox and set the selected item based on the value of the bit flag. I've tried various methods to achieve this, but haven't had any success. I'm not sure if this is even possible, but any help would be appreciated.

Based on the sample below, if my bit flag is set to false, I would like the RadComboBox to have the 2nd item selected. For simplity of this message, I am leaving out the various methods I used to evaluate the bit flag and attempt to set the selection in the sample to avoid confusion.

<telerik:RadComboBox ID="RadComboBox2" runat="server" >
    <Items>
        <telerik:RadComboBoxItem Text="Yes" Value="true" />
        <telerik:RadComboBoxItem Text="No" Value="false" />
    </Items>
</telerik:RadComboBox>

Thanks!

UPDATE:
I was finally able to set the selection after playing a bit more. Seems the value for the bit is case sensitive. I got it working by doing the following:

<telerik:RadComboBox ID="RadComboBox2" runat="server" SelectedValue='<%# Eval("CanBeFatal") %>'>
    <Items>
        <telerik:RadComboBoxItem Text="Yes" Value="True" />
        <telerik:RadComboBoxItem Text="No" Value="False" />
    </Items>
</telerik:RadComboBox>

Guess I spoke to soon. Hope this helps someone else!

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Paul
Top achievements
Rank 1
Share this question
or