Value databinding issues

5 posts, 0 answers
  1. Jon
    Jon avatar
    813 posts
    Member since:
    Oct 2008

    Posted 02 Nov 2011 Link to this post

    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>


  2. Slav
    Admin
    Slav avatar
    1355 posts

    Posted 04 Nov 2011 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jon
    Jon avatar
    813 posts
    Member since:
    Oct 2008

    Posted 04 Nov 2011 Link to this post

    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
  5. Slav
    Admin
    Slav avatar
    1355 posts

    Posted 08 Nov 2011 Link to this post

    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
  6. Jon
    Jon avatar
    813 posts
    Member since:
    Oct 2008

    Posted 09 Nov 2011 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017