开发者

gridview in asp.net

开发者 https://www.devze.com 2022-12-17 01:52 出处:网络
How to make gridview row in bold? I\'ve written the below code to do that but I get error Error2Cannot implicitly convert type \'int\' to \'bool\'

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
                    {
                    }
                }
            }
        }
    }


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;


This is to highlight the error cause only.

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

not

if (ddlread.SelectedIndex = 1)
0

精彩评论

暂无评论...
验证码 换一张
取 消