Dear Sir,
Please help me to make GridView cell font as bold.
protected void GridView1_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
SqlConnection con = new SqlConnection(@"Data Source=10.1.246.4;Initial Catalog=OCMS;User ID=dba_ntpc_meja_intranet;Password=alpha$890;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False");
DropDownList DropDownList1 = (e.Row.FindControl("DropDownList1") as DropDownList);
SqlCommand cmd = new SqlCommand("select * from complaint_status", con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
DropDownList1.DataSource = dt;
DropDownList1.DataTextField = "STATUS_NAME";
DropDownList1.DataValueField = "STATUS_NAME";
DropDownList1.DataBind();
DropDownList1.Items.Insert(0, new ListItem("-Select Status-", "0"));
DropDownList DropDownList2 = (e.Row.FindControl("DropDownList2") as DropDownList);
cmd = new SqlCommand("select * from Assign_to", con);
sda = new SqlDataAdapter(cmd);
dt = new DataTable();
sda.Fill(dt);
DropDownList2.DataSource = dt;
DropDownList2.DataTextField = "STATUS_NAME";
DropDownList2.DataValueField = "STATUS_NAME";
DropDownList2.DataBind();
DropDownList2.Items.Insert(0, new ListItem("-Select Name-", "0"));
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRowView dr = (DataRowView)e.Row.DataItem;
HtmlImage img = e.Row.FindControl("Image1") as HtmlImage;
if (!Convert.IsDBNull(dr["Image"]))
{
(e.Row.FindControl("Image1") as HtmlImage).Src = dr["Image"].ToString();
}
else
{
img.Visible = false;
}
if (e.Row.RowType == DataControlRowType.DataRow && e.Row.RowIndex != GridView1.EditIndex)
{
DateTime time = Convert.ToDateTime((e.Row.FindControl("lblDate") as Label).Text);
if (DateTime.Today.Subtract(time).TotalHours < 3)
{
(e.Row.FindControl("lblDate") as Label).ForeColor = Color.Black;
}
else if (DateTime.Today.Subtract(time).TotalHours > 3)
{
(e.Row.FindControl("lblDate") as Label).ForeColor = Color.Red;
}
(e.Row.FindControl("lblintrcm") as Label).ForeColor = Color.Blue;
string[] stringSeparators = new string[] { "\r\n" };
string[] texts = e.Row.Cells[0].Text.Split(stringSeparators, StringSplitOptions.None);
if (texts.Length > 7)
{
e.Row.Cells[7].Text = string.Format("<b>{0}</b>", texts[0].Trim(), texts[7].Trim());
}
else
{
e.Row.Cells[7].Text = string.Format("<b>{0}</b>", texts[0].Trim());
}
}
}
}