hey,
i m working on Asp.net with C#
i made a table which has username, CheckIntime, Checkouttime and Date in a grid view
i want that customer enter his name in text box and click the submit button then it display his data in table on web page
i do the the coding like this can u plz help me and tell me how can i do this
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.Sql;
using System.Data.SqlClient;
using System.Configuration;
namespace manage_logs
{
public partial class UserView : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// GridView1.Visible = false;
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
SqlCommand cmd = new SqlCommand("select * from [Logs] where name = '" + TextBox1.Text + "'", conn);
//SqlDataReader reader;
conn.Open();
try
{
SqlParameter Username = new SqlParameter();
Username.ParameterName = "@TextBox1.Text";
Username.Value = TextBox1.Text.Trim();
cmd.Parameters.Add(Username);
SqlDataReader dr = cmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(dr);
GridView1.DataSource = dt;
GridView1.DataBind();
SqlParameter search = new SqlParameter();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
//Connection Object Closed
conn.Close();
}
}
}
}