title: How can i attach my datasource from the database inside a gridview?
body: <p>I`m making a mumbai local train timings project as my class project.. how can i attach my datasource from the database inside a gridview??</p>
  
  <pre><code>SqlCommand cmd;
  
  protected void Page_Load(object sender, EventArgs e)
  {
  
  }
  protected void Button1_Click(object sender, EventArgs e)
  {
      con.Open();
  
      cmd = new SqlCommand("Select * from @d where(Select * from @c where Source = @a AND Destination = @b)",con);
      cmd.Parameters.AddWithValue("@d", DropDownList3.SelectedValue);
      cmd.Parameters.AddWithValue("@c",DropDownList3.SelectedValue);
      cmd.Parameters.AddWithValue("@a",DropDownList1.SelectedValue);
      cmd.Parameters.AddWithValue("@b",DropDownList2.SelectedValue);
  
  
  
  
  
      //int i = cmd.ExecuteNonQuery();
  
      //if (i &gt; 0)
      //{
      GridView1.DataSource = //what shud i put here in as a datasource??
      GridView1.DataBind();
      //}
  }
  </code></pre>