how to select a date from calender check that date from database; display those only those data which selected data consist
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;
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
SqlCommand cmd = new SqlCommand("select * from [Logs]", conn);
using (conn)
{
conn.Open();
GridView1.DataSource = cmd.ExecuteReader();
GridView1.DataBind();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
SqlCommand cmd = new SqlCommand("select * from [Logs] where Username = @Username", conn);
try
{
using (conn)
{
conn.Open();
SqlParameter Username = new SqlParameter();
Username.ParameterName = "@Username";
Username.SqlDbType = System.Data.SqlDbType.VarChar;
Username.Value = TextBox1.Text.Trim();
cmd.Parameters.Add(Username);
GridView1.DataSource = cmd.ExecuteReader();
GridView1.DataBind();
GridView1.Visible = true;
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
}
}