sharepoint - programmatically setting the CAML-query on the QueryOverride-member of an custom WebPart that inherits from ContentByQueryWebPart -
The title tells too much, what I see. I created a custom webpart for the SharePoint 2010 solution in Visual Studio 2010, which is derived from ContentByQueryWebPart The purpose of the website is to take an overview of the actions of users, from many work-lists. There is no problem till now.
However, to get some data from URL-query to some custom filtering, grouping and sorting, I have overridden OnInit-Method. The problem is, the custom CQP will not take the CREML string created by me.
I tried some methods already, but none of them wanted to do the job. I might have stripped it down at least that where I set QueryOverride, that location is wrong. (OnInit / OnLoad / before or after the base). **** (E) ;?) For now, it looks like this:
Secure Override Zero OnInit (EventArgs E) {string query = "& lt; query & gt; & Lt; Where & gt; & lt; Eq & gt; & lt; FieldRef Name = \ "Assigned \" / & gt; & lt; Value Type = \ "User \" & gt; & lt; User ID /> gt; & lt; / Eq & gt; & lt; / where & gt; & lt; / query & gt; "; This.QueryOverride = Query; Base.OnInit (E); } I hope someone has an idea. Any help appreciated if something still is not clear, please do not hesitate to ask.
Marcus Schwelbe
Note: English is not my first language, so please forgive me for any mistake in this post :)
I got a solution to do this. It seems that it did not want to be a user id-tag value.
It works like a magic when you use the namespace of the present (or any other) SPUser object Value for "text": (Also, you leave question-tags And can be replaced with ", which looks a bit cleaner")
this.QueryOverride = " I hope this helps anyone who has the same problem. Sincerly,
Marcus Schwelbe
Comments
Post a Comment