Introduction
In this tutorial we will perform the search in our local database. In general we
need to provide some search functionality within our application. We can provide
the simple search facility using this article. For Search we will use the
feature of sql server i.e. Full Text Index Search.
How To Create Full Text
Index In Sql Server?
To create the full text index search see my previous article.
We will use the Full text
search and display the record in datalist control with highlighting the query
words in displayed result as well as paging for datalist control. The
paging used from this article taken from
www.c-sharpcorner.com only.
After reading
How To Create Full Text
Index In Sql Server?
You know now creating full text index now we can move to further step i.e.
designing user interface. So lets start step by step.
Step 1
Download the
attached code and run the script present in QueryScript folder in your database.
That's our database is ready with index. Insert some rows.
Step 2
Start new
website and name it as local_search. Add new page to the application and design
it with Textbox for accepting user query and button to perform the postback and
datalist to display the result.
Step 3
You can copy
and paste this datalist source also. Here we are creating two datalist control
one for displaying results of query and second one for performing paging with
page no.
DataList For Results:
<asp:DataList
ID="dListItems"
runat="server"
onitemdatabound="dListItems_ItemDataBound"
BackColor="White"
BorderColor="#999999"
BorderStyle="None"
BorderWidth="1px"
CellPadding="3"
GridLines="Vertical">
<AlternatingItemStyle
BackColor="#DCDCDC"
/>
<FooterStyle
BackColor="#CCCCCC"
ForeColor="Black"
/>
<HeaderStyle
BackColor="#000084"
Font-Bold="True"
ForeColor="White"
/>
<ItemStyle
BackColor="#EEEEEE"
ForeColor="Black"
/>
<ItemTemplate>
<table>
<tr>
<td>
<asp:Label
ID="lbltitle"
runat="server"
Text='<%#Eval("Title")
%>'
Font-Bold="true"
ForeColor="Blue"
Font-Underline="true"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lbldesc" runat="server" Text='<%#Eval("Desc") %>'></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:HyperLink
ID="hplnavigate"
runat="server"
Font-Bold="false"
ForeColor="#993300"
NavigateUrl='<%#Eval("Link")
%>'
Text="Click Here To
Read More...">

Comments
Join the conversation! Your thoughts help the community grow.