-
Notifications
You must be signed in to change notification settings - Fork 0
/
Default.aspx.cs
62 lines (61 loc) · 2.05 KB
/
Default.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
SqlConnection con = new SqlConnection("data source=172.16.113.13;uid=sa;pwd=server;database=GUESTHOUSE;");
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.SearchCustomers();
}
}
private void SearchCustomers()
{
con.Open();
SqlCommand cmd = new SqlCommand();
string sql = string.Empty;
sql = "SELECT *FROM applicant";
if (!string.IsNullOrEmpty(txtSearch.Text.Trim()))
{
sql += " WHERE appName LIKE @ContactName + '%' OR desg LIKE @ContactName+'%' OR empId LIKE @ContactName+'%' OR email LIKE @ContactName+'%'";
cmd.Parameters.AddWithValue("@ContactName", txtSearch.Text.Trim());
}
cmd.CommandText = sql;
cmd.Connection = con;
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
gvCustomers.DataSource = dt;
gvCustomers.DataBind();
con.Close();
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
Response.Redirect("WebForm4.aspx");
}
protected void gvCustomers_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "EditButton")
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = gvCustomers.Rows[index];
Response.Redirect("~/Default3.aspx?Empno=" +row.Cells[0].Text);
}
}
protected void txtSearch_TextChanged(object sender, EventArgs e)
{
this.SearchCustomers();
}
protected void gvCustomers_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvCustomers.PageIndex = e.NewPageIndex;
this.SearchCustomers();
}
}