yrazlik
yrazlik

Reputation: 10777

Why is not this gridview loading the results?

I am trying to fill the gridview with the search results. Here is the UI of my "AddDropClasses" page:

enter image description here

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

Answers (1)

mshsayem
mshsayem

Reputation: 18008

You forgot to databind showCourses. Add showCourses.DataBind(); after showCourses.DataSource = tab;

Upvotes: 2

Related Questions