C# Gridview数据源没有';t更新
按下一个按钮,我试图用SQL server数据库和其他表更新ASP.net站点上的GridView,但它没有改变,没有“捕获” GridView不会出现C# Gridview数据源没有';t更新,c#,asp.net,database,dataset,sqlcommand,C#,Asp.net,Database,Dataset,Sqlcommand,按下一个按钮,我试图用SQL server数据库和其他表更新ASP.net站点上的GridView,但它没有改变,没有“捕获” GridView不会出现 { SqlConnection sqlConnection1; sqlConnection1 = new SqlConnection(@"Data Source=ELAD_HA\SQLEXPRESS;Initial Catalog=Users;Integrated Security=True");
{
SqlConnection sqlConnection1;
sqlConnection1 = new SqlConnection(@"Data Source=ELAD_HA\SQLEXPRESS;Initial Catalog=Users;Integrated Security=True");
SqlCommand sqlCommand1;
sqlCommand1 = new SqlCommand("SELECT * FROM TBUsers ORDER BY Name", sqlConnection1);
try
{
DataSet ds = new DataSet();
SqlDataAdapter adptr = new SqlDataAdapter(sqlCommand1);
SqlCommandBuilder comb = new SqlCommandBuilder(adptr);
adptr.Fill(ds,"T1");
GridView2.DataSource = ds.Tables["T1"];
//GridView2.DataSource = ds;
//GridView2.DataMember = "T1";
}
catch (SqlException ex)
{
SuccessLabel1.Text = ex.Message.ToString();
}
}
代码有什么问题?P.S
我可以将数据源更改为从菜单中选择数据源的GridView吗?(从“拆分”屏幕)
感谢您的帮助。请尝试呼叫数据绑定以更新内容:
GridView2.DataBind();
致以最诚挚的问候谢谢,我可以将数据源更改为从其菜单中选择数据源的GridView吗?(从“拆分”屏幕)。