Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
535
templated column with checkbox at run time + add events
posted

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

{

 

 

 

public const string  KEY_NAME = DYNAMICCOL_KEY;

 

 

public void InstantiateIn(System.Web.UI.Control container)

{

 

 

CellItem cellitem = ((CellItem )(container));

 

 

CheckBox cb = new CheckBox();

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

Parents
No Data
Reply
  • 7566
    Suggested Answer
    posted

    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();

     

     

    Now the event should be handled.

     

    I hope this helps.

     

    Sincerely,

    Georgi Sashev

    Developer Support Engineer

    Infragistics, Inc.

    http://es.infragistics.com/support

Children