views:

31

answers:

2

How to make gridview row in bold? I've written the below code to do that but I get error

Error   2   Cannot implicitly convert type 'int' to 'bool'

my code is

protected void ddlread_SelectedIndexChanged(object sender, EventArgs e)
    {
        foreach (GridViewRow row in GridView1.Rows)
        {
            if (row.RowType == DataControlRowType.DataRow)
            {
                if (((CheckBox)row.Cells[0].FindControl("chkselect")).Checked == true)
                {
                    if (ddlread.SelectedIndex = 1)
                    {
                        //GridView1.RowStyle.Font.Bold.ToString();
                        row.Font.Bold.ToString();
                    }
                    else
                    {
                    }
                }
            }
        }
    }
+1  A: 

This is to highlight the error cause only.

if (ddlread.SelectedIndex == 1) //double equal

not

if (ddlread.SelectedIndex = 1)
o.k.w
+3  A: 

On line 9, you're trying to convert a bool to an integer. Probably a mistype.

Change the line to:

if (ddlread.SelectedIndex == 1)

To set the font on a row to bold, try this:

row.Font.Bold = true;
alexn
+1 for the bold part. Can't believe I missed it.
o.k.w