Ajax RadSearchBox Control to search FilterRecord

Ajax RadSearchBox Control to search FilterRecord

Introduction : This tutorial explain how to Search filter Data from the Database or from other source By using the Ajax Telerik control called  " telerik:RadSearchBox " using thi control you can find sorted data from the database speedly. the complete code for this control are given below.

First you need to add the "RadScriptManager" in the form control than after add "RadSearchBox2" as below source code.

Step 1 : first you need to install the Telerik control in your visual studio

<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <div>
   
        <table class="style1">
            <tr>
                <td style="text-align: right" class="style2">
                    <telerik:RadSearchBox ID="RadSearchBox2" runat="server"
                        style="margin-left: 0px">
                        <DropDownSettings Height="400" Width="300" />
                    </telerik:RadSearchBox>
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td style="text-align: right" class="style2">
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
        </table>
   
    </div>
    </form>
</body>

Now you can type the code in CodeBehind  as below:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
namespace AjaxControl
{
public partial class SearchBob : System.Web.UI.Page
{
public SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;
AttachDbFilename=D:\\ASearchDB.mdf;Integrated Security=True;User Instance=True");
protected void Page_Load(object sender, EventArgs e)
{
    RadSearchBox2.DataSource = GetData();
    RadSearchBox2.DataTextField = "name";
    RadSearchBox2.DataValueField = "id";
}
public DataTable GetData()
{
DataTable dt = new DataTable();
SqlDataAdapter adp = new SqlDataAdapter
("SELECT *  FROM tbl_user WHERE name Like '%" + RadSearchBox2.Text + "%'", con);
adp.Fill(dt);
return dt;

}
}
}

OutPut: Run project and see the following output:


See Other Tutorial :

*  AngularJS Crude With ASP.NET MVC

*  Convert Rows to columns using 'Pivot' in SQL Server

*  Mvc Registration page With user exist using Ajax method

*  MVC 4 How to Perform Insert Update Delete Edit Select Operation

*  MVC4 Edit,update,Delete,cancel inside gridview using sql database

*  MVC 4 Gridview To Display Data Using SQL Server Database With Simple code 

*  Login page in asp.net Mvc4 Web application

*  Mvc4 How to bind Dropdown List using Sql Database

Gridview find control in asp.net

Previous
Next Post »