Wednesday, April 6, 2011

Error using QueryString, SessionVariables and ViewState in SharePoint

I am doing webparts in sharepoint and I want to transfer the data from one to another. I tried the 3 ways but they all fail. Any idea? It just says An unexpected error has occurred.

From stackoverflow
  • 'Unexpected error' == server error 500? if so, turn on custom error reporting in web.config to find out what the problem actually is.

    Ahmad Farid : now the query string works in some cases and some cases not !!! it says No item exists at http://*******/BIMS/Shared Documents/EditQuestion.aspx?id=3. It may have been deleted or renamed by another user.
  • Google "connected web parts" - there's a built-in, easy way to pass data across parts.

  • Hi Ahmad

    If you want to transfer information from one web part to another on the same page the look at "Connected web parts" as Greg suggest

    If you want to transfer information to web parts on another page the use the query string but don't use names like "id", "listid", "field" which has special meaning to SharePoint like http:/xxx/Shared Documents/EditQuestion.aspx?id=3 which tells SharePoint to load the doc with ID=3 from the Shared Documents and use that as SPContent.Current.Item

    Ahmad Farid : yes man i thx. i changed it to k=3 and it worked!! but cant i use session variables or view state?
    Per Jakobsen : View state can be used without any problem but only works on the single page and you should use it for a control/web part to remeber things which isn't remembered by the html, to communicate with other web-parts use Connections. Session state works fine in MOSS, but is by default disabled in WSS.
  • For the question "No item exists at url, it may have been deleted or renamed by another user", here is good explanation and solution. http://praveenbattula.blogspot.com/2010/02/sharepoint-exception-no-item-exists-url.html

0 comments:

Post a Comment