Custom column templates

2 posts, 0 answers
  1. Gilberto
    Gilberto avatar
    67 posts
    Member since:
    Sep 2006

    Posted 10 Jul 2009 Link to this post

    I am implementing some custom columns templates,  Consulting the samples when i use a "Textbox" as a editor control everything works fine, but if a change to a RadCombo or RadEditor as a main grideditor, i get one error in databinding event, even to insert.

    I am a little confusing about container's, data item, editmode etc.

    Someone to help plz.


     public class ComboItemEditTemplate : ITemplate

            protected RadComboBox comboBox;
            private string columnName;
            protected Field campo;
            protected String errorMessage = string.Empty;
            String connectionString;
            public ComboItemEditTemplate(string ColumnName, string ErrorMessage, Field _Campo, String _connectionString)
                columnName = ColumnName;
                errorMessage = ErrorMessage;
                campo = _Campo;
                connectionString = _connectionString;
            public void InstantiateIn(System.Web.UI.Control container)
                comboBox = new RadComboBox();
                comboBox.ID = String.Format("RadCombo{0}", columnName);
                comboBox.DataBinding += new EventHandler(comboBox_DataBinding);
                comboBox.DataTextField = campo.Description.GetElementsByTagName("DataTextField")[0].InnerText;
                comboBox.DataValueField = campo.relation.PkKey;


            public void comboBox_DataBinding(object sender, EventArgs e)
                RadComboBox combo = (RadComboBox)sender;

                Helper helper = new Helper();

                combo.DataSource = helper.RetornaDatasetCombo(campo, connectionString);

                // GridDropDownColumnEditor container = (GridDropDownColumnEditor)combo.NamingContainer;
                //  combo.SelectedValue = ((DataRowView)container.DataItem)[columnName].ToString();


  2. Sebastian
    Sebastian avatar
    9934 posts

    Posted 15 Jul 2009 Link to this post

    Hello Gilberto,

    How to build grid template columns programmatically you can see from the following help article in the RadGrid documentation: (see the bottom section of the topic)

    In case you use RadComboBox as editor, bind the control to data and receive error on initial insert, consider setting its AppendDataBoundItems property to true and set an empty item in the control or provide predefined value on init insert as explained here (see paragraph 3).

    Best regards,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top