为什么不是这个GridView控件加载的结果? [英] Why is not this gridview loading the results?
问题描述
我想,以填补在搜索结果的GridView控件。这里是我的AddDropClasses页面的UI:
I am trying to fill the gridview with the search results. Here is the UI of my "AddDropClasses" page:
在此页面加载,我想在GridView要填充的当前用户的当前课程,我该使用登记表做。这里是我的code:
When this page is loaded, i want the gridview to be filled the current courses of the current user, and i do this using the Register table. Here is my code:
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = Userfunctions.GetConnectionString();
con.Open();
string query = "select * from RegisterTable where StudentID='" + MyGlobals.currentID + "'";
SqlDataAdapter adap = new SqlDataAdapter(query, con);
DataTable tab = new DataTable();
adap.Fill(tab);
showCourses.DataSource = tab;
}
我载荷(来),该页面从另一个页面点击一个按钮。问题是,该表显示任何结果。当我调试我意识到Myglobals.ID有什么我已经期待值。有什么可以在这里是什么问题?谁能帮助;
I load (come to) this page by clicking a button from another page. The problem is, the table shows no results. When i debugged i realized that Myglobals.ID has the value what i already expect. What can be the problem here? Can anyone help?;
感谢
推荐答案
您忘了数据绑定 showCourses
。添加 showCourses.DataBind();
showCourses.DataSource =标签后;
You forgot to databind showCourses
. Add showCourses.DataBind();
after showCourses.DataSource = tab;
这篇关于为什么不是这个GridView控件加载的结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!