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

how to Select Item from code behind?

5 Answers 1384 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
yare
Top achievements
Rank 1
yare asked on 16 Aug 2011, 09:00 PM
hi all

I have  problem using RadComboBox, I want set item  when my page is load, dependig current month.

I tried use selected item but this action give me a mistake, don't let me add a string.

How can i do this?

help me please 

thank you for you attention 

Good day.

5 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 17 Aug 2011, 07:38 AM
Hello,

Please put below code in your Page_load events and it still not working then put in Page_PreRender event and let me know its working in Page_PreRender or not ?

if (RadComboBox1.FindItemByValue(DateTime.Now.Month.ToString()) != null)
        {
            RadComboBox1.FindItemByValue(DateTime.Now.Month.ToString()).Selected = true;
        }
        else
        {
            // item not found
        }
 
        // or
 
        if (RadComboBox1.FindItemByText(DateTime.Now.Month.ToString()) != null)
        {
            RadComboBox1.FindItemByText(DateTime.Now.Month.ToString()).Selected = true;
        }
        else
        {
             // item not found
        }


Thanks,
Jayesh Goyani
0
yare
Top achievements
Rank 1
answered on 18 Aug 2011, 12:25 AM
thanks Jayesh Goyani

the code is a success :)
0
Rory
Top achievements
Rank 1
answered on 19 Aug 2011, 01:53 AM
 
0
Pravati
Top achievements
Rank 1
answered on 23 Jan 2019, 09:43 AM

Hello, 

 

I have tried this to make item selected , checkbox is getting selected , but when it came to ui it is not displaying , all are unchecked.only

My Combobox is inside telrik rad grid.

Please sugesst

 

0
Marin Bratanov
Telerik team
answered on 25 Jan 2019, 03:16 PM
Hi Pravati,

When checkboxes are used, you must set the Checked property of the combo item to true. Please review the following article for more details on the implementation and API for checkboxes, as they differ from the standard text and value: https://docs.telerik.com/devtools/aspnet-ajax/controls/combobox/functionality/checkbox-support.


Regards,
Marin Bratanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
ComboBox
Asked by
yare
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
yare
Top achievements
Rank 1
Rory
Top achievements
Rank 1
Pravati
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or