This is how you can add a template field in the code behind. You have to handle the WebDataGrid’s Init event, and in the Init event handler (WebDataGrid1_Init in the example) do the following
protected void WebDataGrid1_Init(object sender, EventArgs e)
{
TemplateDataField tempField = new TemplateDataField();
tempField.Key = "MyTempField";
tempField.Header.Text = "My Dynamic Checkbox";
CompiledBindableTemplateBuilder cbtb = new CompiledBindableTemplateBuilder(new BuildTemplateMethod(BuildCheck), null);
tempField.ItemTemplate = cbtb;
this.WebDataGrid1.Columns.Add(tempField);
}
void BuildCheck (Control ctl)
IParserAccessor acess = ctl;
CheckBox ch = new CheckBox();
ch.ID = "check2";
acess.AddParsedSubObject(ch);
Hi Dinesh,
Thanks. I have created the checkbox template column successfully.
How shall i trigger an event for this checkbox
or
how shall i get this checked value from code-behind?
I am googling this for past 2 weeks ... could you provide a solution as soon as possible.
How code if need bound data with TemplateDataField dynamic
Thank you
m