【问题标题】:c# Devexpress datagridview to gridcontrol. manualyc# Devexpress datagridview 到 gridcontrol。手动
【发布时间】:2015-06-02 07:45:37
【问题描述】:
if (connection.State == ConnectionState.Closed)
        {
            connection.Open();
            SqlCommand cmd = new SqlCommand("Select * From YazHata order by HataAdi ASC", connection);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            int sayac = 0;
            dataGridView1.Rows.Clear();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                sayac++;
                dataGridView1.Rows.Add(1);
                dataGridView1.Rows[i].Cells["gwSiraNo"].Value = sayac.ToString();
                dataGridView1.Rows[i].Cells["Hataid"].Value = dt.Rows[i]["id"].ToString();

            }
            da.Dispose();
            connection.Close();


        }

我怎样才能用上面的 devexpress 做到这一点?这个

  • dataGridView1.Rows.Add(1); dataGridView1.Rows[i].Cells["gwSiraNo"].Value = sayac.ToString();

  • dataGridView1.Rows[i].Cells["Hataid"].Value = dt.Rows[i]["id"].ToString();

  • dataGridView1.Rows[i].Cells["HataAdi"].Value = dt.Rows[i]["HataAdi"].ToString();以上..请帮帮我

【问题讨论】:

  • 我不明白你的问题。你能澄清一下吗?究竟是什么不起作用?您收到任何异常或错误消息?
  • Stack Overflow 不存在为您完成工作。请阅读tourHow to Ask 页面。此外,SO 是一个仅限英文的网站。有一个您可能感兴趣的Area 51 proposal for a Turkish Stack Overflow

标签: c# asp.net .net devexpress


【解决方案1】:

您应该使用以下代码使 ASPxGridView 显示该表中的数据:

if (connection.State == ConnectionState.Closed) {
            connection.Open();
            SqlCommand cmd = new SqlCommand("Select * From YazHata order by HataAdi ASC", connection);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            ASPxGridView1.DataSource = dt;  // <<<<
            ASPxGridView1.DataBind();  //<<<<<
            da.Dispose();
            connection.Close();
        }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多