Listview losing viewstate on postback in Sitecore V6

by Aboo Bolaky 21. February 2009 08:23

This post will most probably apply to the GridView and LoginView controls as well.

The Problem

Lets assume that you've successfully bound a listview to your datasource and configured all the properties on the listview to display the Select/Edit/Delete links. You then have the task to write the logic in the appropriate events of the usercontrol/sublayout. While I was implementing the Edit functionality, I implemented the OnItemCommand event of the Listview to display an Edit Panel with the data populated from the selected row. I was a bit suprised to see that the end result wasn't what I was expecting:

The Edit Panel shows up but the Listview has left the party.!!

The Frustration 

It dawned on me that, at some point, I must have messed up somewhere in the code.So, I began putting "EnableViewState=true" to every control.. (this shows how desperate I was!!). I also reverted to "AutoEventFireUp=false" (Originally, I was manually hooking up the events..).I tried databinding on every possible method I could lay my hands on!!. I lost confidence on the fact that this was a really easy task and yet, it was taking me hours to get to the bottom of the problem. I completely lost my mind....I began googling on the issue ["postback..losing viewstate"], I started to watch a few videos that demonstrate the functionality of the ListView..I even got the point where I created another item in Sitecore, assigned the same sublayout to the item's presentation and accessed the item using the url.. I ended up in the same situation.... I surrendered...I left the battlefield...wounded..!!![White flag..Sealed].

The Solution

I finally blamed it on Sitecore!! Who knows, maybe it was a known issue in one of their releases or maybe I just needed to upgrade to the latest stable release(090120). Out of desperation, I tried searching on the Forums and found that I wasn't the only one experiencing this issue.I came across this forum post. Thanks to Mark Cassidy, I eventually finished my task (It had taken me almost a day...and that had messed up (big time) on my initial estimate!!!)

The solution, as Mark outlined, is to add the type of the control (in my case, System.Web.UI.WebControls.ListView) to the typesThatShouldNotBeExpanded element in the web.config. Presumably, for the sake of consistency, you might also append the System.Web.UI.WebControls.Gridview to the list (in case your website makes use of one!!). From what I've read so far, no one knows about the purpose of the typesThatShouldNotBeExpanded element .!! {Sigh...Sitecore!! What did you do that to me????}

In hindsight, only laughs...Good Days...Good Times...

I hope this helps someone!!!

Back to Sitecore  ......

Tags:

.Net | Applications | Sitecore | Tips & Tricks

Comments

5/7/2010 6:42:54 PM #

Russian Girls

Technicality side, your post is easy to understand. At least you've done the right thing to let them know the problem was. Thanks for sharing and more power.

Russian Girls United States |

5/10/2010 5:19:04 PM #

replica watch

Thank you for sharing with us

replica watch United States |

5/13/2010 11:44:10 AM #

family sex

I like the way you write your post because it is sequenced. First , you state the problem and explain what it is to your possible readers. Second, your frustrations, it is like you are stating the possible reactions of someone who might be experiencing the same problem. Finally you gave the solution to the problem which has been very clear to me because of the way you have stated it. So keep it up and more power.

family sex United States |

5/17/2010 5:03:17 PM #

ed hardy Shirt

This blog give me some new source of information. Thanks for sharing it.

ed hardy Shirt People's Republic of China |

5/20/2010 7:34:16 PM #

gps navigator

I am glad to talk with you and you give me great help! Thanks for that, I am wonderring if i can contact you via email when i meet problems?

gps navigator United States |

5/20/2010 7:35:51 PM #

Nike shox shoes

please help me. I'm watching the haunted mansion now. This film is so suck ball. Please suck my ball.

Nike shox shoes United States |

5/24/2010 11:30:04 AM #

cctv spy camera

Thanks for the nice blog. It was very useful for me. I'm happy I found this blog.

cctv spy camera Canada |

5/24/2010 11:30:51 AM #

architectural outdoor lighting


Happy to have found this post.Thanks for such a great post and the review, I am totally impressed! Keep stuff like this coming.
Thanks for the nice blog. It was very useful for me. I'm happy I found this blog.

architectural outdoor lighting Canada |

5/24/2010 11:35:22 AM #

architectural outdoor lighting

The blogsphere changes rapidly, and change creates opportunity.
Thanks a lot for enjoying this beauty article with me.

architectural outdoor lighting Canada |

11/7/2011 1:20:25 PM #

visite Marrakech

I always was attentive in this issue also tranquil am, value it for putting up.

visite Marrakech France |

11/7/2011 1:52:48 PM #

Marrakech guide

I genuinely appreciate looking at on this maze locale , it houses splendid informs .

Marrakech guide France |

11/7/2011 3:39:07 PM #

sejour Marrakech

Nevertheless a smiling visitant here to moiety the enthusiasm (:, btw prominent method . “Forget rue, or soul is yours to skip.” by Jonathan Larson.

sejour Marrakech France |

11/13/2011 12:27:01 PM #

Tout Marrakech

I got what you plan, understand it for putting up.Woh I am grateful to discover this website done google. “The orb of a person creature is a microscope, which prepares the environment appear bigger than it indeed is.” by Kahlil Gibran.

Tout Marrakech France |

11/13/2011 1:02:44 PM #

Voyage Marrakech

Large enter, I accept website owners should secure a lot from this blog its really user pretty. “You don’t get to deserve your mother’s cherish. You get to deserve your beget’s.” by Robert Blight.

Voyage Marrakech France |

11/13/2011 2:59:49 PM #

visite Marrakech

I dugg some of you post as I thought they were very helpful handy

visite Marrakech France |

11/16/2011 3:10:30 AM #

groupe immobilier maroc

Yay google is my ruler aided me to treasure this prominent website ! . “Don’t domineer external employed among your pointers. It does nay forbid using your cranium.” by Freaky Rooney.

groupe immobilier maroc France |

11/16/2011 4:08:43 AM #

immobilier maroc casablanca el jadida

Fine understand, I right passed this onto a associate who was doing some research on that. And he right bought me lunch as I base it for him smile Thus let me rephrase that: Thank you for lunch! “They may forget what you said, but they mind never forget how you made them perceive.” by Carl W. Buechner.

immobilier maroc casablanca el jadida France |

11/16/2011 6:59:39 AM #

vente immobilier maroc

I dugg any of you inform as I imagination they were same cooperative adroit

vente immobilier maroc France |

Tag cloud

Flash Player 9 required.

About Me

I wish I could write something here..
//TODO: ElaborateMe