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 created web part that uses the ListViewByQuery control which is linked to a Document Library. The documents are displayed and all is good.

However, when hovering over the document title to get the context menu (for versioning etc) a message box appears when clicked saying the document no longer exists.

Currently the code really is as simple as:


SPList list = web.Lists[new Guid("XXX")];
SPView view = list.Views[new Guid("XXX")];
SPQuery query = new SPQuery(list.Views[new Guid("XXX")]);
query.ViewFields = fieldList;
this.filteredList.List = list;
this.filteredList.Query = query;

Any ideas? Pointers?

share|improve this question

Use below code, I am not having any such problem

using (SPSite site = new SPSite(SPContext.Current.Web.Url))
                SPWeb currentWeb = site.OpenWeb();

                SPWeb rootWeb = site.RootWeb;
                ListViewByQuery CustomersListViewByQuery = new ListViewByQuery();
                // create the toolbar, actually we cannot hide it, we'll need to extend the webpart and those options
                SPList list = rootWeb.Lists[ListName];
                rootWeb.AllowUnsafeUpdates = true;
                currentWeb.AllowUnsafeUpdates = true;

                string jobNumber = FilterColumn;
                string title = currentWeb.Title;

                CustomersListViewByQuery.List = list;
                string query = null;
                if (!Page.IsPostBack)
                    query = @"<Where><BeginsWith><FieldRef Name='" + jobNumber + "' /><Value Type='Text'>" + title.ToString() + "</Value></BeginsWith></Where>";
                    // apply filtering and/or sorting
                SPQuery qry = new SPQuery(list.DefaultView);
                qry.Query = query;
                CustomersListViewByQuery..Query = qry;


                rootWeb.AllowUnsafeUpdates = false;
                currentWeb.AllowUnsafeUpdates = false;

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.