Hi
we are using ultrawebgrid 10.3 with c#. We are creating templated columns at run time with controls. In this case, it is checkbox. How can I add an server side event to fire when control is created. code is like this:
protected
class PlaceCheckTemplateForDynamic : ITemplate
{
cb.ID =
"chkDynamic";
cb.AutoPostBack =
true;
cb.CheckedChanged += new EventHandler(chkDynamic_CheckedChanged); (not working)
cellitem.Controls.Add(cb);
How can I add the event.
Thanks,
Prathiba
Hello Prathiba,
Thank you for posting in our community. You need to instantiate the control during the Page_Init. Put this code in there:
TemplateDataField tempColumn = new TemplateDataField(true); tempColumn.Key = "TemplateColumn1"; tempColumn.Header.Text = "TemplateColumn"; tempColumn.Width = Unit.Pixel(20); this.WebDataGrid1.Columns.Add(tempColumn, true); TemplateDataField templateColumn1 = (TemplateDataField)this.WebDataGrid1.Columns["TemplateColumn1"]; templateColumn1.ItemTemplate = new CustomItemTemplate();
TemplateDataField tempColumn = new TemplateDataField(true);
tempColumn.Key = "TemplateColumn1";
tempColumn.Header.Text = "TemplateColumn";
tempColumn.Width = Unit.Pixel(20);
this.WebDataGrid1.Columns.Add(tempColumn, true);
TemplateDataField templateColumn1 = (TemplateDataField)this.WebDataGrid1.Columns["TemplateColumn1"];
templateColumn1.ItemTemplate = new CustomItemTemplate();
Now the event should be handled.
I hope this helps.
Sincerely,
Georgi Sashev
Developer Support Engineer
Infragistics, Inc.
http://ko.infragistics.com/support
Were you able to resolve this?
For any further questions do not hesitate to contact me.