SelectedValue Override

10 posts, 0 answers
  1. Olivier
    Olivier avatar
    146 posts
    Member since:
    Nov 2010

    Posted 26 Nov 2012 Link to this post

    Hello

    I need to sub class the RadComboBox, and i want the good syntax to override the SelectedValue,

    Cause i my value isn't find on the list , i want to get the error.

    public override string SelectedValue
        {
            get { return _SelectedValue; }
            set { _SelectedValue = value; }
             
        }

    thanks
    Olivier,
  2. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 29 Nov 2012 Link to this post

    Hello Oliver,

    I am afraid to inform you that we do not support inheritance of our controls. Could you clarify what exactly do you attempt to achieve by overriding the selection of RadComboBox?


    Greetings,
    Nencho
    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. Olivier
    Olivier avatar
    146 posts
    Member since:
    Nov 2010

    Posted 29 Nov 2012 Link to this post

    Ouah ! it's a bad news, all the telerik aren't support inheritance ?

    There a little bug , i want to change.

    If i put a selectedvalue which don't exist in the list, there are a exception : "Selected Value is out of range"

    And i want in the OnPreRender put a little like this, but i don't know  the code here
    base.OnPreRender(e); cause in this method you bind the listitem:

    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e); // here we must to correct the selectedvalue if don't exist
     
        RadComboBoxItem oListItem = base.FindItemByValue("4");
        if(oListItem == null) {
            base.SelectedValue = "";
        }
    }

    Why the selected value don't exist cause , the default value in the database is "0" and the first id is "1".
    and we don't want the null value.

    It's so bad that telerik was closed on inheritance, if telerik is limited , we don't grow up the power of telerik , cause we wait, the evolution all the days , and we choice other way.

    thanks for all.
    olivier
  5. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 04 Dec 2012 Link to this post

    Hello Oliver,

    Unfortunately, based on the provided code snippet I could not replicate the described problem. Could you, please provide us with the implementation that you use, so we can inspect it locally and determine what is causing the issue? 

    Kind regards,
    Nencho
    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. tony
    tony avatar
    5 posts
    Member since:
    Jul 2011

    Posted 04 Dec 2012 Link to this post

    Hello Necho ,

    it's very simple, if you have a list on your combobox like this :

    id  name
    1   customer
    2   seller
    3   supplier

    If your SelectedValue come from your database is "4" for the old value which was deleted, i know it's not possible with a good schema but it's exists.

    telerik RadComboBox say , your selectedvalue is out of range "Exception"

    I want to catch on the pre render the selectedvalue , and i search if it's exist,

    If not Exist i want to put base.selectedvalue="" in the pre render

    thanks
    Olivier

  7. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 06 Dec 2012 Link to this post

    Hello Oliver,

    You could simply check if an item, with the specified value from your database, exists in the ItemsCollections with the help of the FindItemByValue() method in the following manner :

    if (Combo.Items.FindItemByValue("4") != null)
    {
    //do something
    }

    Regards,
    Nencho
    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.
  8. Olivier
    Olivier avatar
    146 posts
    Member since:
    Nov 2010

    Posted 06 Dec 2012 Link to this post

    hello Nencho

    it's exactly that i want to make, but what is this object "Combo"  base object of the class ?
    Cause i had already try in my example up , but the collections Items doesn't instantiate
    in the override SelectedValue.

    What 's the moment telerik instantiate Items on combobox cause the items are null always on the public override SelectedValue?

    if (Combo.Items.FindItemByValue("4") != null)
    {
    //do something
    }
     
    // But the Items is always Null on Public override Selectedvalue
    // my really code

    if (base.Items.FindItemByValue(value) != null)
    {
    //do something
    }


    Olivier,
  9. Cat Cheshire
    Cat Cheshire avatar
    128 posts
    Member since:
    Jun 2010

    Posted 07 Dec 2012 Link to this post

    It is not necessary to inherit the combo just to set a selected item in it.
    Especially as this is not supported.

    You can simply get the combo at server-side and find an item in it by value.
    Or you can use the approach from this forum thread - http://www.telerik.com/community/forums/aspnet-ajax/combobox/setting-an-initial-value-in-radcombobox-while-using-load-on-demand.aspx
  10. Olivier
    Olivier avatar
    146 posts
    Member since:
    Nov 2010

    Posted 07 Dec 2012 Link to this post

    hello,

    We must
    inherit the objects from a framework because we have needs. Because if we change a method for an object we change only one location. I will not depend in 2012, 200 or 300 textbox on my application. I do not even think a developer today to develop apps without inherited base objects.

    Strataframe provides an example source code if we have specific needs to help us with our daily application.

    I have an old database that I can not change the moment with values ​​that are not in my combo box.

    Nencho do not know if the object is instantiated or not items in the properties of the class. It's weird that no member helps when I want to provide a framework Functionality.

    If I had known DevExpress allows heritage objects can be I'll pair it with this framework in order to advance more quickly.

    thank you
  11. Cat Cheshire
    Cat Cheshire avatar
    128 posts
    Member since:
    Jun 2010

    Posted 07 Dec 2012 Link to this post

    Indeed, you can inherit any class - I suppose that your custom implementations in the inheritor methods or properties are not supported. Still this is your custom code.
    I think that setting the selected item as Princy has suggested in the other forum post will save you a lot of time and efforts.

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017