gridview有多列,后台数据绑定,其中有一列的内容只有判断后才能显示,如:某个字段的内容是1就显示,为0就不显示,,,,这是在前台判断还是在后台判断呢,怎么判断呢?<asp:TemplateField ItemStyle-Width="8%" ItemStyle-CssClass="class1">
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server">显示这个内容</asp:HyperLink>
</ItemTemplate>
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server">显示这个内容</asp:HyperLink>
</ItemTemplate>
//相关Row数据处理
protected void GVDesignList_RowDataBound(object sender, GridViewRowEventArgs e)
{ if (e.Row.RowType == DataControlRowType.DataRow)
{
}
Button btnDel = (Button)e.Row.FindControl("GVBtnDel");
if (btnDel != null)
{
btnDel.Attributes.Add("onclick", "return confirm('你确定要删除所选择的数据行吗?');");
}
//删除按钮
if (((Label)e.Row.Cells[60].FindControl("lblAdidName")).Text.Trim() == UserName)
{
((Button)e.Row.Cells[1].FindControl("GVBtnDel")).Enabled = true;
}
else
{
((Button)e.Row.Cells[1].FindControl("GVBtnDel")).Enabled = false; } //颜色 if (((Label)e.Row.Cells[60].FindControl("GVlblactionZK")).Text.Trim() =="已实施")
{
e.Row.Cells[2].ForeColor = System.Drawing.Color.Green;
e.Row.Cells[3].ForeColor = System.Drawing.Color.Green;
e.Row.Cells[4].ForeColor = System.Drawing.Color.Green;
e.Row.Cells[5].ForeColor = System.Drawing.Color.Green; }
else if (((Label)e.Row.Cells[60].FindControl("GVlblactionZK")).Text.Trim() == "未实施")
{ e.Row.Cells[2].ForeColor = System.Drawing.Color.Red;
e.Row.Cells[3].ForeColor = System.Drawing.Color.Red;
e.Row.Cells[4].ForeColor = System.Drawing.Color.Red;
e.Row.Cells[5].ForeColor = System.Drawing.Color.Red;
}
else if (((Label)e.Row.Cells[60].FindControl("GVlblactionZK")).Text.Trim() == "需确认项目")
{ e.Row.Cells[2].ForeColor = System.Drawing.Color.BlueViolet;
e.Row.Cells[3].ForeColor = System.Drawing.Color.BlueViolet;
e.Row.Cells[4].ForeColor = System.Drawing.Color.BlueViolet;
e.Row.Cells[5].ForeColor = System.Drawing.Color.BlueViolet;
}
else if (((Label)e.Row.Cells[60].FindControl("GVlblactionZK")).Text.Trim() == "实施正确项目")
{ e.Row.Cells[2].ForeColor = System.Drawing.Color.Blue;
e.Row.Cells[3].ForeColor = System.Drawing.Color.Blue;
e.Row.Cells[4].ForeColor = System.Drawing.Color.Blue;
e.Row.Cells[5].ForeColor = System.Drawing.Color.Blue;
} //ForeColor backColor } }
執行數據庫時判斷 decode(result,1,'顯示','不顯示')