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

Pb selecting an item when binding to datatable

1 Answer 52 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
CSurieux
Top achievements
Rank 2
CSurieux asked on 18 Aug 2008, 06:58 PM

Hello,

I am binding to an arraylist which contains object  items with properties 'name' and 'val', when I call DataBind, ComboBo items are successfully created, but I'am unable to select one of the items.
It's so trivial that I'm thinking I have an error somewhere else, here is my code:

It runs in the Page_Load event of my page, not other interaction after.
The radCombo is not ajaxified, no autopostback.

            ArrayList ar                    =   im.CategoryList;  
            RadComboCat.DataSource          =   ar;  
            RadComboCat.DataValueField      =   "val";  
            RadComboCat.DataTextField       =   "name";  
            RadComboCat.DataBind();  
            if ( catId == 0 )  
            {  
                RadComboCat.SelectedIndex   =   0;  
            }  
            else  
            {  
                string strCat               =   catId.ToString();  
                 
                Trace2.WriteLine( string.Format("[V]CRMImageEdit FillCatComboSelected FindItemByValue: [{0}], catId:{1}",strCat,catId),CrmImageTrace.Sw.Info);  
                RadComboBoxItem it          =   RadComboCat.Items.FindItemByValue(strCat);  
                  
                Trace2.WriteLine( string.Format("[V]CRMImageEdit FillCatComboSelected FindItemByValue found : {0}", it != null ),CrmImageTrace.Sw.Info);  
                if (it != null)  
                {  
                    it.Selected = true;  
                     
                    Trace2.WriteLine( string.Format("[V]CRMImageEdit FillCatCombo Selected Item: {0}, catId:{1}",it.Text,catId),CrmImageTrace.Sw.Info);  
                }  
            }  
 

Trace shows that the it.Selected= true instruction is executed, but when page is displayed, nothing is selected.
When I select from the UI, the value is well selected and I can store it ????
What could be the reason ?

(Hollidays I know....)

Thanks
CS

1 Answer, 1 is accepted

Sort by
0
Rosi
Telerik team
answered on 19 Aug 2008, 07:39 AM
Hi Christian,

Please find the attached project illustrating that everything works as expected at our side.

You can review it and find the differences at your side.

Regards,
Rosi
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
ComboBox
Asked by
CSurieux
Top achievements
Rank 2
Answers by
Rosi
Telerik team
Share this question
or