Hi,
I am converting a regular asp:drodownlist to a rad ComboBox. It is a year drop down that gets populated on a formula from the code behind. However, I can't seem to get the SelectedValue from the ComboBox in the same way I can from the asp:dropdownlist.
Here is my code behind for populating the asp:dropdownlist:
I changed "ListItem" to "RadComboBoxItem" and the combobox populated correctly. However, upon postback of the combobox value I got an error as if the 'Value' wasn't being read.
Here is the codebehind for pulling the values from the dropdowns:
These worked fine for asp:dropdownlist and for statically configured radcomboboxes. No on the dynamic "year" when using a radcombobox.
Stuck. Any help would be appreciated. Thanks.
joe
I am converting a regular asp:drodownlist to a rad ComboBox. It is a year drop down that gets populated on a formula from the code behind. However, I can't seem to get the SelectedValue from the ComboBox in the same way I can from the asp:dropdownlist.
Here is my code behind for populating the asp:dropdownlist:
| private void BindYears() |
| { |
| DateTime firstyear = DateTime.Now.AddYears(-62); |
| for (int i = 0; i > -47; i--) |
| { |
| DateTime year = firstyear.AddYears(i); |
| ddlYear.Items.Add(new ListItem(year.Year.ToString())); |
| } |
| ddlYear.SelectedIndex = 0; |
| } |
Here is the codebehind for pulling the values from the dropdowns:
| private int Month |
| { |
| get { return Convert.ToInt32(ddlMonth.SelectedValue); } |
| set { ddlMonth.SelectedValue = value.ToString(); } |
| } |
| private int Day |
| { |
| get { return Convert.ToInt32(ddlDay.SelectedValue); } |
| set { ddlDay.SelectedValue = value.ToString(); } |
| } |
| private int Year |
| { |
| get { return Convert.ToInt32(ddlYear.SelectedValue); } |
| set { ddlYear.SelectedValue = value.ToString(); } |
| } |
| public DateTime SelectedDate |
| { |
| get |
| { |
| try |
| { |
| DateTime selecteddate = Convert.ToDateTime(Month + "/" + Day + "/" + Year); |
| return selecteddate; |
| } |
| catch |
| { |
| throw new Exception("The date you selected is not valid"); |
| } |
| } |
| set |
| { |
| try |
| { |
| Month = value.Month; |
| Day = value.Day; |
| Year = value.Year; |
| } |
| catch (Exception ex) |
| { |
| } |
| } |
| } |
These worked fine for asp:dropdownlist and for statically configured radcomboboxes. No on the dynamic "year" when using a radcombobox.
Stuck. Any help would be appreciated. Thanks.
joe