<asp:TemplateField Visible="false">
<ItemTemplate>
<asp:label ID="lblTask" runat="server" Text='<%# Eval("task_status") %>' />
</ItemTemplate>
</asp:TemplateField>
<ItemTemplate>
<asp:label ID="lblTask" runat="server" Text='<%# Eval("task_status") %>' />
</ItemTemplate>
</asp:TemplateField>
然后,
protected void SmartGrid_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
switch (((Label)e.Row.FindControl("lblTask")).Text)
{
case "0":
e.Row.CssClass = "color_task_init";
break;
case "1":
e.Row.CssClass = "color_task_back";
break;
case "2":
e.Row.CssClass = "color_task_wait";
break;
case "3":
e.Row.CssClass = "color_task_confirm";
break;
case "4":
e.Row.CssClass = "color_task_finish";
break;
case "10":
e.Row.CssClass = "color_task_cancel";
break;
case " ":
e.Row.CssClass = "color_terminal";
break;
default:
e.Row.CssClass = "color_terminal";
break;
}
}
}
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
switch (((Label)e.Row.FindControl("lblTask")).Text)
{
case "0":
e.Row.CssClass = "color_task_init";
break;
case "1":
e.Row.CssClass = "color_task_back";
break;
case "2":
e.Row.CssClass = "color_task_wait";
break;
case "3":
e.Row.CssClass = "color_task_confirm";
break;
case "4":
e.Row.CssClass = "color_task_finish";
break;
case "10":
e.Row.CssClass = "color_task_cancel";
break;
case " ":
e.Row.CssClass = "color_terminal";
break;
default:
e.Row.CssClass = "color_terminal";
break;
}
}
}