title: Filling GridView based on DropDownList selected date value
body: <p>I am working a asp.net c# code in order to fill Gridview using sql query and dropdownlist.
  the scenario is :</p>
  
  <ol>
  <li>if dropdownlist selected value is empty then select all from database (select * from table) and fill GridView. That's work perfectly in the visual studio 2008 as well as in the server machine.</li>
  <li>if dropdownlist selected value is a date (this date was selected from the database so it should match one of the column value in the database) then select * from table where date = dropdownlist.selected value. This one is working if i run it using Visual Studio 2008 but give either an empty Grid for some value or an error which said </li>
  </ol>
  
  <blockquote>
    <p>the conversion of a char data type to a datetime data type resulted in an out-of-range datetime value</p>
  </blockquote>
  
  <pre><code>//Page Load
  protected void Page_Load(object sender, EventArgs e)
  {
      if (!IsPostBack)
      {
          Condtion = "";
          this.BindGrid(Condtion);
      }
  }
  
  
  //Fill Grid View
  private void BindGrid( String Condtion )
  {
      string strConnString = ConfigurationManager.ConnectionStrings["ICIRDATAConnectionString1"].ConnectionString;
      using (SqlConnection con = new SqlConnection(strConnString))
      {
  
          String Qsql = "Select * from WeeklyReportView " + Condtion + "";
  
          using (SqlCommand cmd = new SqlCommand(Qsql))
          {
              using (SqlDataAdapter sda = new SqlDataAdapter())
              {
                  cmd.Connection = con;
                  sda.SelectCommand = cmd;
                  using (DataTable dt = new DataTable())
                  {
                      sda.Fill(dt);
                      GridView1.DataSource = dt;
                      GridView1.DataBind();
                  }
              }
          }
      }
  }
  //Drop down List Selected Index Changed
  protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
  {
      DateTime dt;
      if(DropDownList1.SelectedValue!="1")
      {
          dt = DateTime.ParseExact(DropDownList1.SelectedValue, "dd/MM/yyyy hh:mm:ss", new CultureInfo("en-GB"));
          Condtion1 = "wr_week='" + dt + "'";
      }
      Condtion2 = "eng_name='" + DropDownList2.SelectedValue + "'";
      if (DropDownList1.SelectedValue != "1" &amp;&amp; DropDownList2.SelectedValue != "1")
      {
          Condtion = "Where " + Condtion1 + " and " + Condtion2;
      }
      else if (DropDownList2.SelectedValue != "1" &amp;&amp; DropDownList1.SelectedValue == "1")
      {
          Condtion = "Where " + Condtion2;
      }
      else if (DropDownList2.SelectedValue == "1" &amp;&amp; DropDownList1.SelectedValue != "1")
      {
          Condtion = "Where " + Condtion1;
      }
      else
      {
          Condtion = "";
      }
      this.BindGrid(Condtion);
  }
  </code></pre>
  
  <p>Any one can help?</p>