我想要透過DropDownList切換的時候下方的Gridview來顯示資料
然後用Gridview裡的按鈕來修改資料
但是不知道為何我按修改按鈕要按兩次才會有作用
然後這是我的語法
protected void DDL_data_SelectedIndexChanged(object sender, EventArgs e)
{
string sql = "SELECT * FROM "+DDL_data.Text+"";
SQLDB db = new SQLDB();
DataTable dt = db.GetDataTable(sql, CommandType.Text);
GV1.DataSource = dt;
GV1.DataBind();
}
protected void DDL_data_DataBound(object sender, EventArgs e)
{
string sql = "SELECT * FROM " + DDL_data.Text + "";
SQLDB db = new SQLDB();
DataTable dt = db.GetDataTable(sql, CommandType.Text);
GV1.DataSource = dt;
GV1.DataBind();
}
protected void GV1_RowEditing(object sender, GridViewEditEventArgs e)
{
string sql = "SELECT * FROM " + DDL_data.Text + "";
SQLDB db = new SQLDB();
DataTable dt = db.GetDataTable(sql, CommandType.Text);
GV1.DataSource = dt;
GV1.DataBind();
}