none
datagridview中单元格是否为空 RRS feed

  • 问题

  •         private bool DataBindDataGridView2(Model.MasterInfo model, DAL.MasterInfo masterInfo)
            {
                try
                {
                    //this.dataGridView2.DataSource = null;
                    conn = SqlHelper.GetConnnection();
                    sda = new SqlDataAdapter("select * from DetailInfo", conn);
                    SqlCommandBuilder scb = new SqlCommandBuilder(sda);
                    foreach (DataGridViewRow row in dataGridView2.Rows)
                    {
                        row.Cells[1].Selected = true;
                        if (row.Cells[1]!=null) //我用个各种办法判断它是否为空,可是在判断条件的时候却显示不为空或者null,然后将这个值赋给一个Label.Text却又没有值,请教改如何判断datagridview中某行某列的值是或有值呢?
                        {
                            MessageBox.Show("123");
                        }
                        row.Cells["mid"].Value = mid;
                    }
                    sda.Update(this.grainWinFormDataSet.DetailInfo);
                }
                catch (Exception ex)
                {
                    return false;
                }
                clearDataGridView();
                return true;
            }
    2011年9月24日 10:28

答案

全部回复