Tushar Goel

Tushar Goel

  • NA
  • 26
  • 0

Unable to use date through textbox

Feb 13 2011 4:37 AM

Hi,
I need to display the gridview depends upon the date. For this , i used 2 Textbox which take date as an input from the user. Everything works good except the date part. When i am passing the value through textbox, sql query is not working.  Any suggestion?
I am using following query :
protected
void Calendar1_SelectionChanged(object sender, EventArgs e)
{
TextBox1.Text = Calendar1.SelectedDate.ToString();
}
protected void Calendar2_SelectionChanged(object sender, EventArgs e)
{
TextBox2.Text = Calendar2.SelectedDate.ToString();
}

SqlCommand cmd = new SqlCommand("select * where ID.EventStartTime between '" + TextBox1.Text + "' and '" + TextBox2.Text + "' order by ID.EventStartTime desc", con);
con.Open();
SqlDataReader read = cmd.ExecuteReader();
GridView1.DataSource = read;

GridView1.DataBind();
con.Close();
 
 

Regards
Tushar Goel

Answers (1)