gridview in asp.net
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)
精彩评论