Reputation: 10777
I am trying to fill the gridview with the search results. Here is the UI of my "AddDropClasses" page:
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;
}
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?;
Thanks
Upvotes: 0
Views: 59
Reputation: 18008
You forgot to databind showCourses
. Add showCourses.DataBind();
after showCourses.DataSource = tab;
Upvotes: 2