为什么不是这个GridView控件加载的结果? [英] Why is not this gridview loading the results?

查看:159
本文介绍了为什么不是这个GridView控件加载的结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想,以填补在搜索结果的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆