Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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:

and

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

1 Answer 1

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>";
                }
                else
                {
                    // apply filtering and/or sorting
                }
                SPQuery qry = new SPQuery(list.DefaultView);
                qry.Query = query;
                CustomersListViewByQuery..Query = qry;

                this.Controls.Add(CustomersListViewByQuery);

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

            }
share|improve this answer

Your Answer

 
discard

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.