using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.SqlClient; using System.Web.Configuration; public partial class Admin_UsersLoginHistory : System.Web.UI.Page { string conString = ConfigurationManager.ConnectionStrings["KKIAConnectionString"].ToString(); protected void Page_Load(object sender, EventArgs e) { //if (Session["AdminName"] == "") //{ // Response.Redirect("Default.aspx"); //} if (!IsPostBack) { GridData(); } } protected void BtnSearch_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(conString); // I need to search Id , FirstName, LastName,UserName, Department from Gridview. SqlCommand cmd = new SqlCommand("Select * from UserLogs where UserName='" + TxtSearch.Text + "' ", con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); GridView1.DataSource = dt; GridView1.DataBind(); } private void GridData() { SqlConnection con = new SqlConnection(conString); SqlCommand cmd = new SqlCommand("Select * from UserLogs", con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); GridView1.DataSource = dt; GridView1.DataBind(); } }
SELECT * FROM myTable WHERE FirstName='Joe' AND LastName='Smith' AND Department='Chemistry'
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)