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

[Solved] Unable to read RadComboBox selected item

2 Answers 185 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Ken
Top achievements
Rank 2
Ken asked on 02 Apr 2008, 07:35 PM
I am loading four RadComboBoxes with months and years with a simple example I found on your website.  They render just fine in the browser with all the months and years but I cannot read the selected item value from the code-behind.  I load the RadComboBoxes here:

{     
            int startYear = 2003;     
            DateTimeFormatInfo dtfi = new DateTimeFormatInfo();     
            RadComboBoxItem riMs = new RadComboBoxItem();     
            riMs.Text = "Month";     
            riMs.Value = "Month";     
            RadComboBoxItem riMe = new RadComboBoxItem();     
            riMe.Text = "Month";     
            riMe.Value = "Month";     
            RadStartMonth.Items.Add(riMs);     
            RadEndMonth.Items.Add(riMe);     
            for (int month = 1; month < 13; month++)     
            {     
                RadComboBoxItem ris = new RadComboBoxItem();     
                ris.Text = dtfi.GetMonthName(month);     
                ris.Value = dtfi.GetMonthName(month);     
                RadStartMonth.Items.Add(ris);     
                RadComboBoxItem rie = new RadComboBoxItem();     
                rie.Text = dtfi.GetMonthName(month);     
                rie.Value = dtfi.GetMonthName(month);     
                RadEndMonth.Items.Add(rie);     
            }     
            RadComboBoxItem riYs = new RadComboBoxItem();     
            riYs.Text = "Year";     
            riYs.Value = "Year";     
            RadStartYear.Items.Add(riYs);     
            RadComboBoxItem riYe = new RadComboBoxItem();     
            riYe.Text = "Year";     
            riYe.Value = "Year";     
            RadEndYear.Items.Add(riYe);     
            for (int year = startYear; year <= DateTime.Now.Year + 1; year++)     
            {     
                RadComboBoxItem riYYs = new RadComboBoxItem();     
                riYYs.Text = year.ToString();     
                riYYs.Value = year.ToString();     
                RadStartYear.Items.Add(riYYs);     
                RadComboBoxItem riYYe = new RadComboBoxItem();     
                riYYe.Text = year.ToString();     
                riYYe.Value = year.ToString();     
                RadEndYear.Items.Add(riYYe);     
            }     
        }     
 

When the RadComboBox item is selected by the user and clicks the submit button ALL references to RadStartYear.Text, RadStartYear.SelectedValue, etc. are null

What am I doing wrong here?  Am I missing something?

Please do not ask me to send a sample project.  My project is very large and I have sent it to you before and you could not work with it.  I have read all your documentation and examples and do not see what I am missing.

Please just kindly answer my above question.

Thanks much,
Ken


2 Answers, 1 is accepted

Sort by
0
Ken
Top achievements
Rank 2
answered on 02 Apr 2008, 08:37 PM
Important addition to my post - I am not using a 'Button' as I described previously.  I am clicking an item in the RadMenu which is calling my same program with a query string (Dashboard.aspx?Channel=8). 

When I click a button on the page the RadComboBox items are present.  But when I click the RadMenu link my RadComboBox items are all null in the code-behind. 

Is there a way to make the RadComboBox items persist when I click the above link from the RadMenu?

Thanks much,
Ken
0
Nikolay
Telerik team
answered on 03 Apr 2008, 11:45 AM
Hello Ken,

I suppose that the problem appears because you redirect to another page holding the combobox and the selected item is lost. I suggest that you pass the text (or value) of the selected item to the QueryString, find the item in the page_load event of the newly loaded page by using the QueryString parameters and select the item.

This should solve the problem.

Sincerely yours,
Nick
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
ComboBox
Asked by
Ken
Top achievements
Rank 2
Answers by
Ken
Top achievements
Rank 2
Nikolay
Telerik team
Share this question
or