数据未显示在数据网格视图中

时间:2013-11-22 03:36:22

标签: c# .net

数据未在数据网格视图中显示

    objWorOrder = new WorkOrderBAL();
    objProperties = new OMSProperties();
    objProperties.SO = txtsono.Text;
    DataTable dt = objWorOrder.GetDetail(objProperties);// this is for sql database stored procedure
    dgvActSG.DataSource = dt;
    dgvActSG.AutoGenerateColumns = false;
    int rcount = dt.Rows.Count;

    if (dgvActSG.Rows.Count > 0)
    {
        var row = dgvActSG.Rows[0];

        txtcustomer.Text = row.Cells[2].Value.ToString();

        dgvActSG.CurrentCell = row.Cells[0]; //set focus to first cell in first row
    }
    else
    {
        MessageBox.Show("Invalid Number", "Error");
    }

1 个答案:

答案 0 :(得分:0)

我猜你忘了绑定你的gridview

 dgvActSG.DataSource = dt;
dgvActSG.DataBind();
    dgvActSG.AutoGenerateColumns = false;
    int rcount = dt.Rows.Count;