I am creating the checkbox manually by adding templatefield and , but i cannot able to get the value of Checkbox Checked.
my code:
TemplateField tf = new TemplateField();
tf.ItemTemplate = new clsMyTemplate();
CheckBox chkCheckBox1 = new CheckBox();
tf.ItemTemplate.InstantiateIn(chkCheckBox1);
chkCheckBox1.Checked =
(DataBinder.Eval(GrdDynamicControls.Rows[0].DataItem,strColumnName)
.ToString().TrimStart().TrimEnd() == "True" ? true : false);
chkCheckBox1.CheckedChanged += new EventHandler(this.chkCheckBox1_CheckedChanged);
GrdDynamicControls.Columns.Add(tf);
public class clsMyTemplate : ITemplate
{
public void InstantiateIn(System.Web.UI.Control container)
{
CheckBox chkCheckBox1 = new CheckBox();
container.Controls.Add(chkCheckBox1);
}
}
in this line it is showing me error:
chkCheckBox1.Checked =
(DataBinder.Eval(GrdDynamicControls.Rows[0].DataItem,strColumnName)
.ToString().TrimStart().TrimEnd() == "True" ? true : false);
how to get the checked value bindind to it...
any idea???