【问题标题】:Datagrid not showing数据网格不显示
【发布时间】:2016-05-11 10:20:29
【问题描述】:

我的数据网格根本没有出现在我的网页中。就像没有表格出现一样。 我确实关注了这个堆栈question 并修改了它的一些代码以适合我,但它根本没有显示。

这是我的 class 的代码,由按钮触发。

   private void LoadDataGrid()
    {
        con.Open();

        cmd = new SqlCommand(@"SELECT quotationID,quo_product
                             FROM JobQuotations
                             WHERE quo_custname = @custname", con);
        cmd.Parameters.AddWithValue("@custname",lblLoginName.Text);
        da = new SqlDataAdapter(cmd);
        dt = new DataTable();
        GridView1.DataSource = dt;
        GridView1.DataBind();
        con.Close();
    }

我已将它插入到 page_load

 protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
           LoadDataGrid();
        }
    }

这里是标记:

<asp:GridView ID="GridView1" runat="server"></asp:GridView>

【问题讨论】:

标签: c# datagrid


【解决方案1】:

你不见了da.Fill(dt);:

dt = new DataTable();
da.Fill(dt);
GridView1.DataSource = dt;

【讨论】:

  • 让我尝试添加它。等一下。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-12-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多