Hello Memebers,
 
Here I am trying to seach the records based on Job title and job-ID...
 
 Can any one guide me, Thank you in advance!!
 
Below is the ASPX code:
- <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="tquestion.Default" %>  
- <!DOCTYPE html>  
- <html xmlns="http://www.w3.org/1999/xhtml">  
- <head runat="server">  
- <title></title>  
- <style>  
- .text,#GridView1{  
- font-family:'Segoe UI';  
- font-size:11px;  
- }  
- </style>  
- </head>  
- <body>  
- <form id="form1" runat="server">  
- <div style="margin-left:100px;">  
- <table style="width:600px; height:100px;">  
- <tr>  
- <td>  
- <asp:Label ID="lblconsucttechscreen" runat="server" Font-Size="12px" Text="<b>Conduct tech screens</b>"></asp:Label>  
- </td>  
- </tr>  
- <br />  
- <tr class="content-text"><td>  
- <asp:Label ID="lblloadquestions" runat="server" Font-Size="11px" Width="132px" Text="Load questions from template"></asp:Label>  
- <asp:TextBox ID="txtrolename" runat="server" Width="370px" placeholder="Type role name"></asp:TextBox>  
- <asp:Button ID="btnload" runat="server" Text="Load" Width="65px" Height="25px" style="background-color:darkblue; color:white; font-family:'Segoe UI'; font-size:11px; border:1px solid #DCDCDC" OnClick="btnload_Click" />  
- </td></tr>  
- <tr class="content-text"><td>  
- <asp:Label ID="lbljobid" runat="server" Font-Size="11px" Width="132px" Text="Load questions from template"></asp:Label>  
- <asp:TextBox ID="txtjobid" runat="server" Width="370px" placeholder="Type job-id"></asp:TextBox>  
- <asp:Button ID="btnload1" runat="server" Text="Load" Width="65px" Height="25px" style="background-color:darkblue; color:white; font-family:'Segoe UI'; font-size:11px; border:1px solid #DCDCDC" OnClick="btnload_Click" />  
- </td></tr>  
- </div>  
- <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" HeaderStyle-ForeColor="White" HeaderStyle-BackColor="#000099" >  
- <Columns>  
- <asp:BoundField ItemStyle-Width="50px" DataField="job_id" HeaderText="Job-id" />  
- <asp:HyperLinkField DataTextField="Jobtitle" ItemStyle-Width="90px" HeaderText="Job title" SortExpression="Jobtitle" />  
- <asp:BoundField ItemStyle-Width="245px" DataField="Jobdescription" HeaderText="Job description" />  
- <asp:BoundField ItemStyle-Width="65px" DataField="createdby" HeaderText="Created by" />  
- <asp:BoundField ItemStyle-Width="120px" DataField="createddate" HeaderText="Created date" />  
- </Columns>  
- </asp:GridView>  
- </form>  
- </body>  
- </html>
 
CS code:
- using System;  
- using System.Collections.Generic;  
- using System.Linq;  
- using System.Web;  
- using System.Web.UI;  
- using System.Web.UI.WebControls;  
- using MySql.Data.MySqlClient;  
- using System.Data;  
- using System.Configuration;  
- namespace tquestion  
- {  
- public partial class Default : System.Web.UI.Page  
- {  
- protected void Page_Load(object sender, EventArgs e)  
- {  
- if (!this.IsPostBack)  
- {  
- this.BindGrid();  
- }  
- }  
- private void BindGrid()  
- {  
- string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;  
- using (MySqlConnection con = new MySqlConnection(constr))  
- {  
- using (MySqlCommand cmd = new MySqlCommand("SELECT job_id,Jobtitle, Jobdescription, createdby, createddate FROM questions"))  
- {  
- using (MySqlDataAdapter sda = new MySqlDataAdapter())  
- {  
- cmd.Connection = con;  
- sda.SelectCommand = cmd;  
- using (DataTable dt = new DataTable())  
- {  
- sda.Fill(dt);  
- GridView1.DataSource = dt;  
- GridView1.DataBind();  
- }  
- }  
- }  
- }  
- }  
- protected void OnPaging(object sender, GridViewPageEventArgs e)  
- {  
- GridView1.PageIndex = e.NewPageIndex;  
- this.BindGrid();  
- }  
- protected void btnload_Click(object sender, EventArgs e)  
- {  
- string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;  
- using (MySqlConnection con = new MySqlConnection(constr))  
- {  
- using (MySqlCommand cmd = new MySqlCommand("SELECT * FROM questions WHERE Jobtitle = '@Jobtitle';"))  
- {  
- cmd.CommandType = CommandType.Text;  
- cmd.Connection = con;  
- con.Open();  
- using (MySqlDataReader sdr = cmd.ExecuteReader())  
- {  
- sdr.Read();  
- txtrolename.Text = sdr["Jobtitle"].ToString();  
- }  
- con.Close();  
- }  
- }  
- }  
- }  
- }