Thursday, February 19, 2009

Sort a Data View Web Part based on QueryString

There was a requirement where I have to sort a data view webpart on multiple parameters like date, size and LOB. Initially I thought of having three different pages for sorting, but that is very bad idea. So thought of implementing it with the concept of query string.

I want to use the sort option provided by data view web part and provide SortField as query string parameter. After thinking for a while and providing multiple hit and trials I have succeeded. Below is the expression for sorting using query string.

@*[name()= $SortField]

We write this in the edit sort expression.

And in the URL….

http://ServerName/Lists/Deals/LOB.aspx?LOB=All&SortField=Deal_x0020_Date



No comments:

Post a Comment