Gostaria de que uma determinada linha de meu GridView
fique vermelha caso a célula correspondente da coluna closed esteja com valor falso.
Meu ASP.Net está assim:
div class="GridMain">
<asp:GridView ID="gvInformationPeriod" runat="server" Width="100%" CssClass="GridViewUser" AllowPaging="True" CellPadding="4" AutoGenerateColumns="False"
GridLines="None" ForeColor="#333333" OnPageIndexChanging="gvInformationPeriod_PageIndexChanging" onrowdatabound ="gvInformationPeriod_RowDataBound" PageSize="100">
<AlternatingRowStyle CssClass="GridAlternativeUser" BackColor="White" />
<Columns>
<asp:BoundField DataField="PeriodID" HeaderText="PeriodID" />
<asp:BoundField DataField="SchoolID" HeaderText="SchoolID" />
<asp:BoundField DataField="DateOpen" HeaderText="Aberto Em" />
<asp:BoundField DataField="UserName" HeaderText="Usuario" />
<asp:BoundField DataField="PCName" HeaderText="PC Name" />
<asp:BoundField DataField="Closed" HeaderText="Closed" />
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#62AFC1" CssClass="GridPagerUser" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
</div>
Meu ASPX.CS carrega o GridView
assim:
private void ListarGridInformationPeriod()
{
if (ddlSchool.SelectedValue != "")
{
gvInformationPeriod.Visible = true;
gvInformationPeriod.DataSource = Period.ListOpenPeriod(int.Parse(ddlSchool.SelectedValue));
gvInformationPeriod.DataBind();
}
}
protected void gvInformationPeriod_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
if (!string.IsNullOrEmpty(ddlSchool.SelectedValue))
{
gvInformationPeriod.PageIndex = e.NewPageIndex;
gvInformationPeriod.DataSource = Period.ListOpenPeriod(int.Parse(ddlSchool.SelectedValue));
gvInformationPeriod.DataBind();
}
}
Pensei em colocar alguma coisa conforme abaixo usando o RowDataBound
mas não funcionou
protected void gvInformationPeriod_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Equals("false"))
{
e.Row.BackColor = Color.Red;
}
}
}
Tentei usar o conteúdo desse post mas não entendi bem
https://stackoverflow.com/questions/5048762/change-gridview-row-color-based-on-condition-in-c-sharp