SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a web part with SPGridView. I defined TemplateField for SPGridView.

 TemplateField tmp = new TemplateField();
 tmp.HeaderText = field.Title;
 tmp.ItemTemplate = new AddTemplateToGridView(ListItemType.Header, field.InternalName);

when load page, all data display , but when filter or sort a column , don't display item in template field.

share|improve this question

My guess is that your code to add the column is not in a method that is called on post back.

I recommend reviewing the ASP.NET control lifecycle.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.