On my Windows form, I have a RadDateTimePicker control. When I first load the form, I'm retrieving data from our database, based on the value of a .NET ComboBox control, and populating the RadDateTimePicker control from a date column in the return result set. If I then change the value in my ComboBox, which initiates a fresh hit to the database, and the date column is null, it clears the RadDateTimePicker control as I want it to.
The problem comes when I change the ComboBox back to the value it was when the form first loaded, forcing a retrieval of the original data. The RadDateTimePicker control stays empty, even though the Value property has a valid date.
If I click the drop down arrow of the RadDateTimePicker control at this point, the text suddenly fills in with the correct date. Here's the code I'm using:
The problem comes when I change the ComboBox back to the value it was when the form first loaded, forcing a retrieval of the original data. The RadDateTimePicker control stays empty, even though the Value property has a valid date.
If I click the drop down arrow of the RadDateTimePicker control at this point, the text suddenly fills in with the correct date. Here's the code I'm using:
| // Create PMA object |
| ProductMarketArea pma = new ProductMarketArea(); |
| // Retrieve product data |
| DataTable tbl = pma.GetRecordsByProductID(CurrentProduct.ID.Value); |
| // Get specific PMA data. |
| DataRow row = tbl.Select("MarketAreaID = " + CurrentMarketArea.MarketAreaID.ToString() + " And Expiration Is Null")[0]; |
| // Populate PMA object with PMA data. |
| pma.LoadFromDataRow(row); |
| _ProductMarketArea = pma; |
| EventHandler datesChanged = DatesChanged; |
| rdpStartDate.ValueChanged -= datesChanged; |
| rdpEndDate.ValueChanged -= datesChanged; |
| // rdpStartDate and rdpEndDate are the two RadDateTimePicker controls |
| if (pma.StartDate.HasValue) |
| rdpStartDate.Value = pma.StartDate.Value; |
| else |
| rdpStartDate.Value = DateTime.Now; |
| // PROBLEM SEEMS TO BE HERE. END DATE STAYS VISUALLY EMPTY AFTER RECORD CHANGE |
| if (pma.EndDate.HasValue) |
| rdpEndDate.Value = pma.EndDate.Value; |
| else |
| rdpEndDate.Value = rdpEndDate.MinDate; |
| rdpStartDate.ValueChanged += datesChanged; |
| rdpEndDate.ValueChanged += datesChanged; |