日期:2014-05-17 浏览次数:20444 次
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { string test=e.Row.Cells[6].Text.Trim();//看看这里的值是什么? if (e.Row.RowType == DataControlRowType.DataRow) { if (Convert.ToInt32(e.Row.Cells[6].Text.Trim()) <= 0 || Convert.ToInt32(e.Row.Cells[6].Text.Trim()) < 60) { e.Row.Cells[6].ForeColor = System.Drawing.Color.Red; } }
------解决方案--------------------
<form id="form1" runat="server"> <div> <asp:GridView ID="gv" runat="server" AutoGenerateColumns="false" onrowdatabound="gv_RowDataBound"> <Columns> <asp:TemplateField> <ItemTemplate> <asp:Label ID="lblGrade" runat="server" Text='<%#Eval("Grade") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </div> </form>