Pb selecting an item when binding to datatable

2 posts, 0 answers
  1. CSurieux
    CSurieux avatar
    465 posts
    Member since:
    Jan 2007

    Posted 18 Aug 2008 Link to this post


    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";  
                if ( catId == 0 )  
                    RadComboCat.SelectedIndex   =   0;  
                    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....)


  2. Rosi
    Rosi avatar
    2529 posts

    Posted 19 Aug 2008 Link to this post

    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.

    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top