I use column generator in List page template to generate command column, hide some columns, set column alignment and size, etc(with some attribute I defined). There is a problem about ViewState and some entities sort and paging functionality causes the error
that contains:
Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back
must match the type and position of the controls added during the initial request.
Based on the following threads I think the problem is the timing of setting column generator:
I set column generator in Load event of List page template because in Init event of Page and GridView It has no effect. The solution provided in the first thread does not work becuase I do more than hiding columns and the second solution is for prior 4.0
.Net framework. Any solution to resolve the issue.
I'll have to try running here in a sample project, as I don't use field generators for my project any more I only use them to set the item style wrap on columns I do all my field filtering in custom meta models. An I see you are doing some clever stuff in
there I'll look late next week.
See my blog C# Bits | Twitter @sjnaughton Always seeking an elegant solution.
Sorry Ali, I must be being a little Dumb I think the issue is the Command Column try removing that from the Field Generator and see what happens. I remember I have tried moving the Command column this way and had issues in the end I gave up and I only use
the IAutoFieldGenerator to handle Column Wrap and other formatting. I use a custom Metamodel to do field and Filter ordering etc.
See my blog C# Bits | Twitter @sjnaughton Always seeking an elegant solution.
The problem was that I need command field and it didn't work until I transferred field generator from Init event to Load event and then there was the problem of ViewState. Provided this situation I think there is no way except using ListView in list templte.
I saw your MetaModel approach but it does not work with my other requirements.
Member
130 Points
229 Posts
List page template column generator problem
Jul 17, 2014 12:57 AM|IranianCuriousBoy|LINK
Hi
I use column generator in List page template to generate command column, hide some columns, set column alignment and size, etc(with some attribute I defined). There is a problem about ViewState and some entities sort and paging functionality causes the error that contains:
Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.
Based on the following threads I think the problem is the timing of setting column generator:
http://forums.asp.net/t/1678747.aspx?Failed+to+load+viewstate+
http://forums.asp.net/t/1353129.aspx?Failed+to+load+viewstate
I set column generator in Load event of List page template because in Init event of Page and GridView It has no effect. The solution provided in the first thread does not work becuase I do more than hiding columns and the second solution is for prior 4.0 .Net framework. Any solution to resolve the issue.
Thanks
All-Star
17916 Points
5681 Posts
MVP
Re: List page template column generator problem
Jul 17, 2014 06:41 AM|sjnaughton|LINK
Hi ali, I use column generators all the time and have no issues could you post your code please?
Always seeking an elegant solution.
Member
130 Points
229 Posts
Re: List page template column generator problem
Jul 18, 2014 12:03 AM|IranianCuriousBoy|LINK
Hi
The code follows. There are some extension methods that hopefully are clear to understand:
Thanks
All-Star
17916 Points
5681 Posts
MVP
Re: List page template column generator problem
Jul 18, 2014 02:39 AM|sjnaughton|LINK
Hi Ali, I suspect it's the command field that is causing the issue I suggest commenting that out an testing.
Always seeking an elegant solution.
Member
130 Points
229 Posts
Re: List page template column generator problem
Jul 19, 2014 07:03 AM|IranianCuriousBoy|LINK
Hi Stephen, It still does not work.
All-Star
17916 Points
5681 Posts
MVP
Re: List page template column generator problem
Jul 20, 2014 07:55 AM|sjnaughton|LINK
I'll have to try running here in a sample project, as I don't use field generators for my project any more I only use them to set the item style wrap on columns I do all my field filtering in custom meta models. An I see you are doing some clever stuff in there I'll look late next week.
Always seeking an elegant solution.
Member
130 Points
229 Posts
Re: List page template column generator problem
Jul 22, 2014 01:02 AM|IranianCuriousBoy|LINK
Thanks
All-Star
17916 Points
5681 Posts
MVP
Re: List page template column generator problem
Jul 22, 2014 04:16 AM|sjnaughton|LINK
Sadly, I'm going to be away next week now so it will have to wait until I get back if I can't look by Thursday
Always seeking an elegant solution.
Member
130 Points
229 Posts
Re: List page template column generator problem
Jul 25, 2014 03:11 PM|IranianCuriousBoy|LINK
OK
Member
130 Points
229 Posts
Re: List page template column generator problem
Sep 15, 2014 01:14 PM|IranianCuriousBoy|LINK
Hi Steve
I think there is no way except reimplementing List Page template with ListView. What's your opinion?
All-Star
17916 Points
5681 Posts
MVP
Re: List page template column generator problem
Sep 16, 2014 05:13 AM|sjnaughton|LINK
Sorry Ali, I must be being a little Dumb I think the issue is the Command Column try removing that from the Field Generator and see what happens. I remember I have tried moving the Command column this way and had issues in the end I gave up and I only use the IAutoFieldGenerator to handle Column Wrap and other formatting. I use a custom Metamodel to do field and Filter ordering etc.
Always seeking an elegant solution.
Member
130 Points
229 Posts
Re: List page template column generator problem
Sep 17, 2014 02:23 AM|IranianCuriousBoy|LINK
The problem was that I need command field and it didn't work until I transferred field generator from Init event to Load event and then there was the problem of ViewState. Provided this situation I think there is no way except using ListView in list templte. I saw your MetaModel approach but it does not work with my other requirements.
Thanks anyway
All-Star
17916 Points
5681 Posts
MVP
Re: List page template column generator problem
Sep 17, 2014 04:43 AM|sjnaughton|LINK
OK I got you and see what you need, there may be a way around this but at the moment I'm not sure but will get back to you if I find a solution.
Always seeking an elegant solution.
Member
130 Points
229 Posts
Re: List page template column generator problem
Sep 17, 2014 06:18 AM|IranianCuriousBoy|LINK
Thanks