简体   繁体   中英

data is not shown in data grid view

Data is not showing in data grid view

    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");
    }

I guess you forgot to bind your gridview

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM