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

Value databinding issues

4 Answers 68 Views
Slider
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 02 Nov 2011, 03:57 PM
Hi,

When using the slider I am noticing some odd behaviour.  I have a set of criteria 1-5 and in the database I store which one of them was chosen.  Now If I use the code as below with the database value of 1, the second entry in the list is selected, setting the value in the database to 0 (which in practice it should never be) causes the first item to be selected.  It's almost as if the slider is treating the value as a 0 based array index.... Any ideas?  Code follows:

<telerik:RadSlider ID="uxOQC_1" runat="server"  DbValue='<%# Bind("OQC_1") %>' MinimumValue="1" MaximumValue="5" ItemType="Item" TrackPosition="Center">
   <Items>
       <telerik:RadSliderItem Text="Strongly disagree" Value="1" ToolTip="Strongly disagree" runat="server"></telerik:RadSliderItem>
       <telerik:RadSliderItem Text="Disagree" Value="2" ToolTip="Disagree" runat="server"></telerik:RadSliderItem>
       <telerik:RadSliderItem Text="Neither agree nor disagree" Value="3" ToolTip="Neither agree nor disagree" runat="server"></telerik:RadSliderItem>
       <telerik:RadSliderItem Text="Agree" Value="4" ToolTip="Agree" runat="server"></telerik:RadSliderItem>
       <telerik:RadSliderItem Text="Strongly agree" Value="5" ToolTip="Strongly agree" runat="server"></telerik:RadSliderItem>
   </Items>
</telerik:RadSlider>


4 Answers, 1 is accepted

Sort by
0
Slav
Telerik team
answered on 04 Nov 2011, 03:00 PM
Hello Jon,

Please note that when the ItemType property of the RadSlider is set to Item, the items in the Items collection define the possible values for the slider. The Value property of the slider in this case represents the index in the Items collection of the currently selected slider item. This is why when you specify a value 1, the item with this index, which is the second item, is selected.

In order to set as selected the item of the slider control, corresponding to passed value, you should specify the correct index in the Items collection, as demonstrated below:
int selectedItemValue = 3;
RadSlider1.SelectedValue = RadSlider1.Items[selectedItemValue - 1].Value;

In the provided example the value of the selected item is 3 and the index, passed to the Items collection, is 2 in order to reference the third item.

Greetings,
Slav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Jon
Top achievements
Rank 1
answered on 04 Nov 2011, 03:08 PM
Hi Stav,

Thanks for the explanation.  I have a work around in place however it is very bad planning to have selectedvalue in fact refering to the selectedindex.  I assume this was an accident in the original programming of the component?

Regards,

Jon
0
Slav
Telerik team
answered on 08 Nov 2011, 05:37 PM
Hi Jon,

Indeed, it will be more intuitive to be able to set the selected item directly. This matter will be brought to the attention of our developers and an improvement will be considered, although I cannot provide a firm estimate when it will be available. I have logged the feature as a PITS Issue and you can check it by following this link: Public URL.

Please accept our apologies for the caused inconvenience. I have updated your telerik points accordingly.

Best wishes,
Slav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Jon
Top achievements
Rank 1
answered on 09 Nov 2011, 09:43 AM
Hi Slav,

Many thanks.  

The main issue with rectifying the issue is that it would possibly go unnoticed and cause more issues.  

Best Regards,

Jon
Tags
Slider
Asked by
Jon
Top achievements
Rank 1
Answers by
Slav
Telerik team
Jon
Top achievements
Rank 1
Share this question
or