content templatecolumn disappears after sorting or filtering

3 posts, 0 answers
  1. Paul Evers
    Paul Evers avatar
    52 posts
    Member since:
    Oct 2011

    Posted 21 Feb 2013 Link to this post

    Hi,

    I have a RadGrid with a templatecolumn which I create programmatically.

    GridTemplateColumn templateColumn = new GridTemplateColumn();
    RadGrid1.MasterTableView.Columns.Add(templateColumn);
    templateColumn.ItemTemplate = new WorkflowStatusTemplate();

    After performing an action in the grid (like sort or filtering) the content of the templatecolumn is empty.

    Do I have to rebind the templatecolumn again after such an action?

    Paul

  2. MasterChiefMasterChef
    MasterChiefMasterChef avatar
    152 posts
    Member since:
    Jan 2013

    Posted 21 Feb 2013 Link to this post

    Hi Paul,

    Is your RadGrid inside of an Ajax panel? If not, the filter / sort will cause a postback, reverting the grid to its original loaded state. This may have something to do with why your templatecolumn is losing all of its bound data.

    Hopefully this helps,
    Master Chief
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 21 Feb 2013 Link to this post

    Hi,

    Here is the code that I tried which worked as expected.
    C#:
    protected void Page_Init(object sender, System.EventArgs e)
    {
           RadGrid1 = new RadGrid();
            RadGrid1.ID = "RadGrid1";
         RadGrid1.AllowSorting = true;
       NewTemplateColumn templateColumn = new NewTemplateColumn();
            templateColumn.HeaderText = "sample";
            templateColumn.SortExpression = "EmployeeID";
            templateColumn.ItemTemplate = new TemplateColumn();
          RadGrid1.MasterTableView.Columns.Add(templateColumn);
     PlaceHolder1.Controls.Add(RadGrid1);
    }
     public partial class NewTemplateColumn : GridTemplateColumn
        {
            public void InstantiateIn(Control container)
            {
              
             
            }
        }
    public partial class TemplateColumn : ITemplate
    {
      public void InstantiateIn(Control container)
      {
        //define template column here
      }
    }

    Also check the following help documentation which explains more about this.
    Programmatic Creation

    Thanks,
    Shinu
Back to Top