This is a migrated thread and some comments may be shown as answers.

content templatecolumn disappears after sorting or filtering

2 Answers 55 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul Evers
Top achievements
Rank 2
Paul Evers asked on 21 Feb 2013, 04:27 PM
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 Answers, 1 is accepted

Sort by
0
MasterChiefMasterChef
Top achievements
Rank 2
answered on 21 Feb 2013, 09:09 PM
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
0
Shinu
Top achievements
Rank 2
answered on 22 Feb 2013, 05:34 AM
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
Tags
Grid
Asked by
Paul Evers
Top achievements
Rank 2
Answers by
MasterChiefMasterChef
Top achievements
Rank 2
Shinu
Top achievements
Rank 2
Share this question
or