日期:2014-05-18  浏览次数:20449 次

Select语句头快爆炸!高手指点!
Gridview结构:
审核部门 审核状态 审核人 通过审核日期
Users表结构:
UserName…………..UserBm…………LxSh……….
LxSh表结构:
…………..BmName………...UserName……..TgTime 

问题:
想实现在Gridview中的“审核部门”列显示Users表中的LxSh=1的distinct(UserBm)列。
GridView中的“审核状态”列显示如果LxSh表中BmName=User.UserBm那么该行显示“通过审核”否则显示“没通过审核”。
GridView中的“审核人”和“通过审核日期”两列,如果“审核状态”列为“通过审核”则分别显示LxSh表中的UserName和TgTime如果“审核状态”为“没通过审核”这两列则显示“无”。
这样的邦定GridView的select语句我该怎么写!!!


------解决方案--------------------
C# code

 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if(e.Row.RowType==DataControlRowType.DataRow)
        {
            
            if (e.Row.Cells[4].Text.Trim() == "0")
            {
                e.Row.Cells[4].Text = "<font color=red>隐藏</font>";
            }
            else 
            {
                e.Row.Cells[4].Text = "公开";
            }
            if (e.Row.Cells[5].Text.Trim() == "0")
            {
                e.Row.Cells[5].Text = "<font color=red>新留言</font>";
            }
            else 
            {
                e.Row.Cells[5].Text = "已回复";
            }
                 
        }
    }

------解决方案--------------------
可以判断审核状态
if (审核状态通过)
 {
全部显示
 }
if (审核状态没通过)
 {
this.WaterGridView1.Columns[0].Visible = fasle;
this.WaterGridView1.Columns[1].Visible = fasle;
 }
隐藏对应的gridview列