我正在将孟买当地的火车时刻表项目作为我的课程项目。我如何将我的数据源从数据库中附加到 gridview 中?
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 > 0)
//{
GridView1.DataSource = //what shud i put here in as a datasource??
GridView1.DataBind();
//}
}