我有一个页面和下拉列表中的下拉列表我有数据库中的表名称。 我不知道如何从gridview或datalist中选定的表中插入数据。如何从下拉列表中选择表格中的数据?
我试图使用的代码从另一个C#项目我在学校表现,但没有奏效
编辑:答案补充这里
protected void Button1_Click(object sender, EventArgs e)
{
OleDbConnection con = new OleDbConnection(connectionString);
OleDbDataAdapter da = new OleDbDataAdapter (string.Format("SELECT * from {0}", dropDownList.SelectedValue), con);
DataSet ds = new DataSet();
da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
da.Fill(ds);
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
con.Close();
}
什么你到目前为止尝试过吗?张贴在这里,我们可以指出你在正确的方向。为了将来的参考,如果你在某个特定的编程问题上发帖,而不是要求为你编写整个代码块,你会在SO上得到更好的结果。 –