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 am to use SharePoint Designer, no custom c# code.

I am currently using a SharePoint:SPDataSource on a DVWP to show a list. When the SelectCommand is blank, it works fine but I will need to create dynamic filter.

Working Data Source:

 <SharePoint:SPDataSource runat="server" DataSourceMode="List" SelectCommand="" UseInternalName="True" UseServerDataFormat="True" ID="spdatasource2">

I have a choice field, myField which is either 'Public' or 'Private', currently I am only looking to find items with 'Public'. I have tried:

 SelectCommand="<View><Query><Where><Eq><FieldRef Name='myField'/><Value Type='Text'>Public</Value></Eq></Where></Query></View>"

Errors: One or more field types are not installed properly

Also

 Selectcommand="&lt;View&gt;&lt;Query&gt;&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name=&quot;myField&quot;/&gt;&lt;Value Type=&quot;Text&quot;&gt;Public&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;&lt;/Query&gt;&lt;/View&gt;"

Errors: Cannot Complete this action


Eventually I am looking to build an equivalent of

 SelectCommand  = "Select * From myList Where myField like '"+@selectParam1+"'"
  <SelectParameter ID='selectParam1' DefaultValue="*" Location="QueryString"/>


I have also tried to use ajax on the address:

/vit_bin/owssvr.dll?Cmd=Display&List={guid}&View={guid}&XMLDATA=True&Query=*

This always downloads a file of the default view instead of show xml causing the POST request to fail.

Another attempt was to use xsltListViewWebPart but I could not get a valid query in that either.

Advice?

share|improve this question

1 Answer 1

Change <Value Type='Text'> to <Value Type='Choice'> in the SelectCommand CAML query

See MSDN - SPFieldType Enumeration for the different values you can use for each field type.

share|improve this answer
    
Can you explain why this should work? Since we don't even know the field type of the custom field –  Robert Lindgren Oct 2 '13 at 11:56
    
@Robert the op has stated "I have a choice field, myField which is either 'Public' or 'Private'" –  Aquila Sands Oct 2 '13 at 12:28
    
True, I missed that, sorry! But I still see no good cause to use Choice instead of Text as Value Type, do you have a good source for that statement? –  Robert Lindgren Oct 2 '13 at 12:44
    
@Robert quiet right I should have provided that! I've updated my answer to include a reference for the different values. –  Aquila Sands Oct 2 '13 at 14:06
    
Great, but these are FieldTypes, not the value types that SharePoint actually stores. Have you tried your solution? (Asking out of curiosity, since I find this interesting) –  Robert Lindgren Oct 2 '13 at 16:10

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.