I'm trying to get a RadDatePicker to properly postback on my RadGrid. I'm creating the object dynamically since depending on the row type, I want different types of controls in the column.
To start, inside ItemCreated, I'm doing this to create the control:
In this code, indExpDate is set to either my data (if the item.DataItem is available) or to "" (if not).
This is the same code that I'm using to create my TextBox objects as well, which are working fine.
The control is properly created initially, showing the date that I want. When I post back in an ItemCommand, the SelectedDate is always NULL, and when the page redraws following the postback, the field is blank. This only happens if I don't change the control value - once I change the control value, all is well.
As I said, TextBox works fine. I create the control the same way, set the .Text property, can read the data during ItemCommand, and the value comes back when the postback completes. RadDatePicker is the only one that I'm having trouble with.
Any ideas?
Thanks - Matt
To start, inside ItemCreated, I'm doing this to create the control:
DateTime tmpDate;
item[
"Column2"
].Controls.Add(
new
RadDatePicker() {
ID =
"phDate"
,
SelectedDate = DateTime.TryParse( indExpDate,
out
tmpDate ) ? (DateTime?)tmpDate :
null
} );
This is the same code that I'm using to create my TextBox objects as well, which are working fine.
The control is properly created initially, showing the date that I want. When I post back in an ItemCommand, the SelectedDate is always NULL, and when the page redraws following the postback, the field is blank. This only happens if I don't change the control value - once I change the control value, all is well.
As I said, TextBox works fine. I create the control the same way, set the .Text property, can read the data during ItemCommand, and the value comes back when the postback completes. RadDatePicker is the only one that I'm having trouble with.
Any ideas?
Thanks - Matt