By request I'm developing a custom WebPart where it's possible for the user to search files and folders inside a document library, i made a GridView to list the files (working ok I'm not searching), a TextBox for input and a button.
My document library structure is something like this:
- Document Library
- Child Folder 1
- Child Folder 2
- Grand Child Folder
- Image.jpg
When using the search I created, I type the name 'Image'. But it always returns nothing (SPListItemCollection.count is always 0).
For the search, i'm using the following code:
SPQuery query = new SPQuery();
query.ViewAttributes = "Scope='RecursiveAll'";
String caml = @"<Where>
<Contains>
<FieldRef Name='Title' />
<Value Type='Text'>{0}</Value>
</Contains>
</Where>
<OrderBy>
<FileRef Name='ID' Ascending='True' />
</OrderBy>";
query.Query = String.Format(caml, "Image");
SPListItemCollection resultGetItems = list.GetItems(query);
Anyone can help me with this one? i can't seem to get it working.
Thanks a lot.