I have a radgrid that I am dynamically creating in the Page_Init method as mentioned here. I have multiple templated columns that dispaly a label in the ItemTemplate and a RadComboBox and RadTimePicker in the EditItemTemplate. Both are properly displayed. However, on editing in batch mode, I am only able to get the value of the radcombobox and not of the time picker. I have noticed that the DataBinding events of my EditItemTemplate controls do not fire at all. Even the overridden ExtractValues method doesnt hit my breakpoint. Have attached the code..Any help is appreciated.
public class MyItemTemplate : IBindableTemplate { protected Label lblProj; private string colName; public MyItemTemplate(string cName) { colName = cName; } public void InstantiateIn(System.Web.UI.Control container) { lblProj = new Label(); lblProj.ID = "ProjTime_" + colName; lblProj.Width = Unit.Pixel(140); lblProj.DataBinding += new EventHandler(lblProj_DataBinding); container.Controls.Add(lblProj); } void lblProj_DataBinding(object sender, EventArgs e) { Label lblProj = (Label)sender; GridDataItem container = (GridDataItem)lblProj.NamingContainer; lblProj.Text = ((DataRowView)container.DataItem)[colName].ToString(); } public IOrderedDictionary ExtractValues(Control container) { OrderedDictionary values = new OrderedDictionary(); return values; } }
public class MyEditTemplate : ITemplate
{
protected RadComboBox PDay;
protected static string date;
protected static string time;
protected RadTimePicker PTime;
private string colName;
public MyEditTemplate(string cName)
{
colName = cName;
}
public IOrderedDictionary ExtractValues(Control container)
{ //breakpoint here doesnt get hit
OrderedDictionary values = new OrderedDictionary();
return values;
}
public void InstantiateIn(System.Web.UI.Control container)
{
PDay = new RadComboBox();
PDay.ID = "PDay_" + colName;
PDay.Width = Unit.Pixel(150);
PDay.AllowCustomText = true;
PDay.DataBinding += new EventHandler(PDay_DataBinding);
//adding Items to PDay.Items here
PTime = new RadTimePicker();
PTime .ID = "PTime_" + colName;
PTime .Width = Unit.Pixel(100);
PTime .DataBinding += new EventHandler(PTime_DataBinding);
PTime .DateInput.ReadOnly = true;
container.Controls.Add(PDay);
container.Controls.Add(PTime );
}
void PTime_DataBinding(object sender, EventArgs e)
{ //breakpoint here doesnt get hit
RadTimePicker timePicker = (RadTimePicker)sender;
GridDataItem container = (GridDataItem)timePicker.NamingContainer;
timePicker.SelectedDate = Convert.ToDateTime(((DataRowView)container.DataItem)[colName].ToString());
}
public void PDay_DataBinding(object sender, EventArgs e)
{ //breakpoint here doesnt get hit
RadComboBox cBox = (RadComboBox)sender;
GridDataItem container = (GridDataItem)cBox.NamingContainer;
cBox.Text = ((DataRowView)container.DataItem)[colName].ToString();
}
}