具体情况类似于
http://topic.csdn.net/u/20080927/13/a1ae08fb-1568-4237-9ce0-f7555fc40555.html?seed=1365244606&r=60453920#r_60453920
CheckSign列数据库为int型,但需要根据需要设置相应的值如 for (int i = 0; i < dgvPatientList.Rows.Count; i++)
            {
                dgvPatientList.Rows[i].Cells["CheckSign"].Value = "已审核";
                if (dgvPatientList.Rows[i].Cells["CheckSign"].Value.ToString().Equals("0"))
                {
                    dgvPatientList.Rows[i].Cells["CheckSign"].Value = "已审核";
                }
                else
                {
                    dgvPatientList.Rows[i].Cells["CheckSign"].Value = "已审核";
                }
            }
会报错DataError数据类型错误

解决方案 »

  1.   


            private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
            {
                if (e.RowIndex == -1) return;
                if (e.ColumnIndex == 0)
                {
                    if (Convert.ToInt32(e.Value) == 1)
                        e.Value = "a";
                }
            }
      

  2.   

    你也可以直接在SQL下直接转换