This is a migrated thread and some comments may be shown as answers.
SelectedValue Override
9 Answers 50 Views
This is a migrated thread and some comments may be shown as answers.
Olivier
Top achievements
Rank 2
Olivier asked on 26 Nov 2012, 06:23 PM
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,

9 Answers, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 29 Nov 2012, 04:49 PM
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.
0
Olivier
Top achievements
Rank 2
answered on 29 Nov 2012, 05:10 PM
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
0
Nencho
Telerik team
answered on 04 Dec 2012, 03:20 PM
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.
0
tony
Top achievements
Rank 1
answered on 04 Dec 2012, 04:20 PM
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

0
Nencho
Telerik team
answered on 06 Dec 2012, 05:22 PM
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.
0
Olivier
Top achievements
Rank 2
answered on 06 Dec 2012, 06:43 PM
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,
0
Cat Cheshire
Top achievements
Rank 1
answered on 07 Dec 2012, 08:44 AM
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
0
Olivier
Top achievements
Rank 2
answered on 07 Dec 2012, 09:13 AM
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
0
Cat Cheshire
Top achievements
Rank 1
answered on 07 Dec 2012, 09:38 AM
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.

Asked by
Olivier
Top achievements
Rank 2
Answers by
Nencho
Telerik team
Olivier
Top achievements
Rank 2
tony
Top achievements
Rank 1
Cat Cheshire
Top achievements
Rank 1
Share this question
or