Friday, November 04, 2005

Site Search Using Windows Catalog Service




string strCatalog = "Test";

string strQuery = "Select Filename,VPath,Path from SCOPE()
where FREETEXT('" + TextBox1.Text + "') ";

string connString = "Provider=MSIDXS;Data Source='" + strCatalog + "'";

OleDbConnection Connection = new OleDbConnection(connString);
Connection.Open();
OleDbDataAdapter da = new OleDbDataAdapter(strQuery, Connection);

DataSet ds = new DataSet();
da.Fill(ds);
Connection.Close();

DataView source= new DataView(ds.Tables[0]);
DataGrid1.DataSource = source;
DataGrid1.DataBind();

XSL Key


you can segregate distinct values using xsl:key from XML



<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="Brand-Id" match="//row" use="@BrandId"/>

<xsl:template match="/">
<table cellpadding="4" Id="xsltable" width="70%" align="center">
<tr class="tablecontent2">
<td>
<xsl:apply-templates
select="/Root/row[generate-id()=generate-id(key('Brand-Id',@BrandId)[1])]"
mode="Brand"/>
</td>
</tr>
</table>
</xsl:template>


<xsl:template match="row" mode="Brand">
<xsl:variable name="brandid" select="@BrandId"/>
<xsl:value-of select="/Root/row[@BrandId=$brandid]/@BrandName"/>

</xsl:stylesheet>

Transform XML to HTML Using XSL

<asp:Xml id="xml1" DocumentSource="Dynamic.XML" TransformSource="Dynamic.xsl" runat="server" />