GRIDVIEW中有个绑定列 数据库中字段值 为1,2,3等
想实现效果为 当为1时,GRIDVIEW中显示 "处理 "
当为2时,GRIDVIEW中显示 "处理中 "
谢谢
------解决方案--------------------------------------------------------
你的datasource是怎么取的
如果是sql的话,直接case when就可以了
------解决方案--------------------------------------------------------
同意楼上,可以在RowDataBound中处理,也可以将所有数据放到一个dataset里面处理数据后和GRIDVIEW绑定
------解决方案--------------------------------------------------------
给GridView添加RowDataBound消息
if(e.Row.RowType == DataControlRowType.DataRow)
{
if(e.Row.Cells[...].Text == "1 ")
{
e.Row.Cells[...].Text = "处理 ";
}
else if(e.Row.Cells[...].Text == "2 ")
{
e.Row.Cells[...].Text = "处理中 ";
}
}
------解决方案--------------------------------------------------------
protected void GVRc_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[9].Text.Trim() == "禁用 ")
{
e.Row.Cells[9].Text = "点击启用 ";
}
else if (e.Row.Cells[9].Text.Trim() == "启用 ")
{
e.Row.Cells[9].Text = "点击禁用 ";
}
}
}