因为在数据库中审核和未审核的信息用数字表示(“0”表示未审核,“1”表示已审核),但在显示时不能显示“0”或者“1”,所以必须把其转换成相应的 汉字。想实现代码如下:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[4].Text == "0")
{
e.Row.Cells[4].Text = "未审核";
}
else
{
e.Row.Cells[4].Text = "<font color=red>已审核</font>";
}
((LinkButton)(e.Row.Cells[6].Controls[0])).Attributes.Add("onclick", "return confirm('确定删除吗?')");
}
}
protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
string id=this.GridView1.DataKeys[e.NewSelectedIndex].Value.ToString();
SqlConnection strcon = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["strcon"]);
strcon.Open();
SqlCommand scd = new SqlCommand("select Auditing from tb_OldTruck where id=" + id, strcon);
string Auditing = Convert.ToString(scd.ExecuteScalar());
if (Auditing == "0")
{
Auditing = "1";
}
else
{
Auditing = "0";
}
scd.CommandText = "update tb_OldTruck set Auditing=" + Auditing + " where id=" + id;
scd.ExecuteNonQuery();
this.bind();
strcon.Close();
}
为什么当我填完一个注册用户信息提交注册成功,但还没审核,而此时会显示“审核”状态?
好郁闷啊