Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

SearchResult web part

  Asked By: Candice    Date: Nov 21    Category: Sharepoint    Views: 666

Has anybody used SearchResult web part.
I have created a custom web part in which i am calling SearchResult web part
and assigning to QueryTemplatewherePart the where condition ,but it does not
display any result

what can be the possible error?
I have attached code for reference

SearchResults searchResult = new SearchResults();

searchResult.Visible = true;

searchResult.Title ="Search Results";

searchResult.TextForNoResults ="No Results found";

// Generate the query

string wherestart="where WITH (
\"DAV:contentclass\":0,\"urn:schemas.microsoft.com:fulltextqueryinfo:description\
\":0,\"urn:schemas.microsoft.com:fulltextqueryinfo:sourcegroup\":0,\"urn:schemas\
.microsoft.com:fulltextqueryinfo:cataloggroup\":0,\"urn:schemas-microsoft-com:of\
fice:office#Keywords\":1.0,\"urn:schemas-microsoft-com:office:office#Title\":0.9\
,\"DAV:displayname\":0.9,\"urn:schemas-microsoft-com:publishing:Category\":0.8,\\
"urn:schemas-microsoft-com:office:office#Subject\":0.8,\"urn:schemas-microsoft-c\
om:office:office#Author\":0.7,\"urn:schemas-microsoft-com:office:office#Descript\
ion\":0.5,\"urn:schemas-microsoft-com:sharepoint:portal:profile:PreferredName\":\
0.2,contents:0.1,*:0.05 ) AS #WeightedProps (";

string whereend=" ) ";

string scopepart="( ( FREETEXT ('%"+
txtSearchValue.Text+ "' %') OR FREETEXT(#WeightedProps, '% " +
txtSearchValue.Text + "%') OR CONTAINS ('% "+ txtSearchValue.Text + "%*')) AND
CONTAINS
(\"urn:schemas.microsoft.com:fulltextqueryinfo:Sourcegroup\",'\"%__searchscope__\
%\"') ) OR";

string sitepart="( ( FREETEXT ('%"+ txtSearchValue.Text
+"%') OR FREETEXT(#WeightedProps, '%"+txtSearchValue.Text +"%') OR CONTAINS
('%" + txtSearchValue.Text+"%*')) AND ( CONTAINS (\"DAV:href\",'%__sitename__%')
) )";

System.Text.StringBuilder builder=new
System.Text.StringBuilder();

builder.Append(wherestart);

foreach(DataRow s in drArray)

{


builder.Append(scopepart.Replace("%__searchscope__%",s[0].ToString()));

}


builder.Append(sitepart.Replace("%__sitename__%","Msource"));

builder.Append(whereend);

searchResult.QueryTemplateWherePart=builder.ToString();

placeholder.Controls.Add(sb);

placeholder.Controls.Add(searchResult);

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on SearchResult web part Or get search suggestion and latest updates.




Tagged: