Click here to Skip to main content
15,897,291 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi frds,

I am using c# for creating a Checkbox in radgrid using GridTemplateColumn to bind data from database dynamically. it was working fine for binding . But I need to raise a event when we checked the check box on radgrid cell. I am using below code for binding checkbox in gridtemplate column. Pls reply if u know the answer...tq..

public class MyTemplate : ITemplate
{
protected CheckBox rgAdminChk;
private string colname;
public MyTemplate(string cName)
{
colname = cName;
}
public void InstantiateIn(System.Web.UI.Control container)
{
rgAdminChk = new CheckBox();
rgAdminChk.ID = colname;
rgAdminChk.DataBinding += new EventHandler(boolValue_DataBinding);
container.Controls.Add(rgAdminChk);
}
void boolValue_DataBinding(object sender, EventArgs e)
{
CheckBox cBox = (CheckBox)sender;
GridDataItem container = (GridDataItem)cBox.NamingContainer;
if (!string.IsNullOrEmpty((DataBinder.Eval(container.DataItem, colname)).ToString()))
cBox.Checked = Convert.ToBoolean((DataBinder.Eval(container.DataItem, colname)).ToString());
else
cBox.Checked = false;
}


}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900