Telerik Bug with Dynamic Checkbox in ItemTemplateColumn seems to be having an issue with Postback

2 posts, 0 answers
  1. Deepak Vasudevan
    Deepak Vasudevan avatar
    82 posts
    Member since:
    May 2010

    Posted 17 Nov 2011 Link to this post

    I am having a GridTemplateColumn with a checkbox that is  being dynamically created. I  need to have this checkbox with an ability to AUTOPOSTBACK but the autopostback event never seems to fire. The browser does not fire the event consistently and also even when it fires the event handler is never reached.

    Looks like it is a bug in Telerik RadGrid as this post shows.

    Is there a workaround or fix for the same?
  2. Jayesh Goyani
    Jayesh Goyani avatar
    2733 posts
    Member since:
    May 2010

    Posted 18 Nov 2011 Link to this post


    There is not any such type of issue with Radgrid please check below code snippet.
    public class MyTemplate : System.Web.UI.Page, ITemplate
        protected CheckBox boolValue;
        private string colname;
        public MyTemplate(string cName)
            colname = cName;
        public void InstantiateIn(System.Web.UI.Control container)
            boolValue = new CheckBox();
            boolValue.ID = "boolValue";
            boolValue.AutoPostBack = true;
      protected void Page_Load(object sender, EventArgs e)
            RadGrid RadGrid5 = new RadGrid();
            RadGrid5.ID = "RadGrid5";
            RadGrid5.AutoGenerateColumns = false;
            GridTemplateColumn templateColumn = new GridTemplateColumn();
            string templateColumnName = "ContactName";
            templateColumn.ItemTemplate = new MyTemplate(templateColumnName);
            templateColumn.HeaderText = templateColumnName;
            RadGrid5.ItemDataBound += new GridItemEventHandler(RadGrid5_ItemDataBound);
            dynamic data = new[] {
                    new { CustomerId = 1, CustomerName = 2,Bool = true},
                    new { CustomerId = 4, CustomerName = 5,Bool = false}
            RadGrid5.DataSource = data;
     void RadGrid5_ItemDataBound(object sender, GridItemEventArgs e)
            if (e.Item is GridDataItem)
                GridDataItem item = e.Item as GridDataItem;
                CheckBox boolValue = item.FindControl("boolValue") as CheckBox;
                boolValue.CheckedChanged += new EventHandler(boolValue_CheckedChanged);
        void boolValue_CheckedChanged(object sender, EventArgs e)
            Response.Write((sender as CheckBox).Checked.ToString());

    Let me know if any concern.

    Jayesh Goyani
Back to Top