How to check the status (True/False) in a grid view on rowdatabound event?

Posted by NayeemKhan on Stack Overflow See other posts from Stack Overflow or by NayeemKhan
Published on 2011-02-17T06:28:32Z Indexed on 2011/02/17 7:25 UTC
Read the original article Hit count: 110

Filed under:
|

Hi all, I have a table with three columns (ProdID,ProdName,Status). I m fetching that into a dataSet and binding that to my gridview. I have a very basic and simple rowdatabound event like this :

 protected void gvProducts_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if (e.Row.Cells[2].Text == "False")
            {
                e.Row.BackColor = System.Drawing.Color.PaleVioletRed;
            }
        }
    }

But when i see my 3rd column (Status), it is converted to a checkbox, may be becz its containing only 'True' or 'False'. Also in my if condition :

if (e.Row.Cells[3].Text == "False")

the text value is showing this :

""

Can anybody suggest me, how can i compare my status against True or False in my if condition.

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET