fogofogo
09-05-2007, 07:13 AM
Hello,
I'm trying to check through a gridview and highlight cells that contain errors. The code below should check if a cell is empty and if it is, fill the background with red. I plan to add other checks, but need to get this working first.
<asp:GridView ID="errorgrid" runat="server" AutoGenerateColumns="False" EnableViewState="False" OnRowDataBound="errorgrid_RowDataBound">
<Columns>
<asp:BoundField DataField="CasinoName" HeaderText="CasinoName"/>
<asp:BoundField DataField="JTTransDate" HeaderText="JTTransDate"/>
<asp:BoundField DataField="CashinID" HeaderText="CashinID" />
</Columns>
</asp:GridView>
protected void errorgrid_RowDataBound(object sender,GridViewRowEventArgs e)
{
if (e.Row.Cells[0].Text == "")
{
//e.Row.BackColor = System.Drawing.Color.Red;
//Response.Write("Error");
errorgrid.BackColor = System.Drawing.Color.Red;
}
}
The code doesnt actually display any error message, nor does it highlight the empty cells. Anyone know what I'm doing wrong?
Thanks
I'm trying to check through a gridview and highlight cells that contain errors. The code below should check if a cell is empty and if it is, fill the background with red. I plan to add other checks, but need to get this working first.
<asp:GridView ID="errorgrid" runat="server" AutoGenerateColumns="False" EnableViewState="False" OnRowDataBound="errorgrid_RowDataBound">
<Columns>
<asp:BoundField DataField="CasinoName" HeaderText="CasinoName"/>
<asp:BoundField DataField="JTTransDate" HeaderText="JTTransDate"/>
<asp:BoundField DataField="CashinID" HeaderText="CashinID" />
</Columns>
</asp:GridView>
protected void errorgrid_RowDataBound(object sender,GridViewRowEventArgs e)
{
if (e.Row.Cells[0].Text == "")
{
//e.Row.BackColor = System.Drawing.Color.Red;
//Response.Write("Error");
errorgrid.BackColor = System.Drawing.Color.Red;
}
}
The code doesnt actually display any error message, nor does it highlight the empty cells. Anyone know what I'm doing wrong?
Thanks