filter to a gridview in c#
<p>I Have a gridview having column
names(batchname,firstname,schedule,startdate,enddate,labname)</p>

<p>I want to add a filter to a gridview. Can I add a filter bellow each column of the gridview header.Or Should i use it outside the gridview? Here I m using it outside the gridview.And fire a event of TextChanged.I have done following code but it doesnt work anymore.Please Suggest a solution.</p>

<p>I have to access data from three tables to show in gridview.The three
table formats are as below,</p>

<pre><code>BatchMaster(batchmasterid,usermasterid,labmasterid,batchname,batchcode,batchdays,startdate,enddate)

UserMaster(usermasterid,title,firstname,middlename,lastname,phoneno);

LabMaster(labmasterid,labname);
</code></pre>

<p>I write a code on textbox change event whitch is taken outside the gridview.</p>

<pre><code>protected void txtSearch_TextChanged(object sender, EventArgs e)
       {
           SqlConnection con = new SqlConnection("Data
Source=.\\SQLEXPRESS;Initial Catalog=EMS;User ID=sa;Password=sa123");
           string query = "SELECT
batchmasterid,usermasterid,labmasterid,batchname,faculty,batchdays,startdate,enddate,LabMaster.labname
FROM BatchMaster,UserMaster Where batchname LIKE '%" + txtSearch.Text
+ "%'";
           SqlCommand cmd = new SqlCommand(query, con);
           SqlDataAdapter da = new SqlDataAdapter(cmd);
           DataSet ds = new DataSet();
           da.Fill(ds);
           gvHeadload.DataSource = ds;
           gvHeadload.DataBind();

      }
</code></pre>

<p>also I have tried a Join Query. But it doesnt work anymore.
Pls suggest a solution as early as possible.
advanced thank u for ur suggation..</p>
