DataGridView列中值变换问题

来源:百度知道 编辑:UC知道 时间:2024/05/19 10:01:52
this.dataGridView3.DataSource = company.CompanyGetByID(id, "", "");
foreach (DataGridViewRow row in dataGridView3.Rows)
{
if (this.DataGridView3.Columns["VIPLevel"].value= "0")
{
DataGridView.Columns["VIPLevel"].Text = "普通会员";
}
else if (DataGridView.Columns["VIPLevel"].Text == "1")
{
DataGridView.Columns["VIPLevel"].Text = "理事会员";
}
else if (DataGridView.Columns["VIPLevel"].Text == "2")
{
DataGridView.Columns["VIPLevel"].Text = "VIP会员";
}
}
弄出来不对

this.dataGridView3.DataSource = company.CompanyGetByID(id, "", "");
foreach (DataGridViewRow row in dataGridView3.Rows)
{
if (row.Cells["VIPLevel"].value= "0")
{
row.Cells["VIPLevel"].value= "普通会员";
}
else if (row.Cells["VIPLevel"].value== "1")
{
row.Cells["VIPLevel"].value= "理事会员";
}
else if (row.Cells["VIPLevel"].value== "2")
{
row.Cells["VIPLevel"].value= "VIP会员";
}
}

第一个条件判断里
if (this.DataGridView3.Columns["VIPLevel"].value== "0")

用 row["VIPLevel"].Value 试一下

不是DATAGRIDVIEW3么?