ListViewByQuery w/ a view using a custom xsl
-
2012年6月27日 13:41
Can you use the ListViewByQuery to display a view that has a custom XSL specified in it's xsllink?
The view displays properly but when used through the ListViewByQuery it doesn't show up. Is there somewhere in the ListViewByQuery where you need to specify it is a different XSL?
Or do you have to use the XSLTListViewWebPart whenever you are using a non-standard XSL?
Thanks!
Drew Block
全部回复
-
2012年6月28日 9:14版主
Hi drew,
ListViewByQuery can be used with view that with custom xsl, I create a view for a list, use SharePoint Designer to add custom xsl for the view page, then create a web part and add ListViewByQuery control, it works as expected, the code snippet is:
ListViewByQuery view = new ListViewByQuery();SPWeb currentweb = SPContext.Current.Web;
SPList list = currentweb.Lists["list2"];
view.List = list;
SPView listview = list.Views["myview"];
SPQuery query = new SPQuery(listview);
query.ViewFields = "<FieldRef Name='Title'/>";
query.Query = "<Where><Contains><FieldRef Name='Title'/><Value Type='Text'>q</Value></Contains></Where>";
view.Query = query;
EnsureChildControls();
view.RenderControl(writer);
RenderChildren(writer);
To narrow down the issue, please make sure that you have custom the view correctly. Or you can share your custom xsl for the view to do further research.
Thanks,
Qiao Wei
TechNet Community Support
- 已标记为答案 Qiao WeiMicrosoft Contingent Staff, Moderator 2012年7月5日 10:23

