62,074
社区成员
发帖
与我相关
我的任务
分享
protected void Page_Load(object sender, EventArgs e)
{
Bind();
}
dbMethod dbM = new dbMethod();
public void Bind()
{
string str = "select * from tb_Cars";
DataTable dt = dbM.GetDataTable(str);
this.GridView1.DataSource = dt;
this.GridView1.DataBind();
}
protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
string carID = this.GridView1.DataKeys[e.NewSelectedIndex].Value.ToString();
string str = "select * from tb_Cars where carID='" + carID + "'";
DataTable dt = dbM.GetDataTable(str);
this.GridView2.DataSource = dt;
this.GridView2.DataBind();
}