This tutorial shows how simple it is to allow users to search a database for matching text they input themselves. C# version.

Searching a website is often taken for granted. Implementing a search facility on a website used to be rather complex. However, as with many things in ASP.NET, it has gotten much easier. This tutorial will show how we can implement a simple search facility to allow users to input text and search a database for matching records.
First, we need to add the following assembly reference:

In the Web.config, we declare the connection string:


The ASPX page will consist of a textbox, a button and a repeater control to display the results. It will look something like this:

In the code-behind, we will reference a Stored Procedure, which will be something like this:

The code-behind should look something like this:

Download Source Files