简略代码:
select tmp,buf from incliddataGridView1.DataSource = ds.Tables[0].DefaultView;查询inclid表结果显示在dataGridView1
字段tmp存储的是1和2,显示在dataGridView1上时1为学生,2为老师,
有办法能在查询语句或者给dataGridView1赋值前判断tmp值来转换成学生或者老师?
select tmp,buf from incliddataGridView1.DataSource = ds.Tables[0].DefaultView;查询inclid表结果显示在dataGridView1
字段tmp存储的是1和2,显示在dataGridView1上时1为学生,2为老师,
有办法能在查询语句或者给dataGridView1赋值前判断tmp值来转换成学生或者老师?
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
if (e != null)
{
if (e.ColumnIndex == dataGridView1.Columns["tmp"].Index)
{
string value = dataGridView1.Rows[e.RowIndex].Cells["tmp"].Value.ToString();
if (value == "1")
{
e.Value = "学生";
}
else
{
e.Value = "教师";
}
e.FormattingApplied = true;
}
}
1 学生
2 老师查询语句这样写select b.b,a.buf from inclid a, tablea b where a.tmp=b.a