how to change specific cells backcolor if cells has no data in gridview in asp.net
my code is here..
- for (int i = 0; i < GridView1.Row.Cells.Count; i++)
- {
- if (GridView1.Row[i].Cells[2].Text == "")
- {
- GridView1.Row[i].Cells[2].BackColor = Color.Red;
- }
- else
- {
- GridView1.Row[i].Cells[2].BackColor = Color.Green;
- }
- }

Amit KumarPosted Dec 25, 2017, 4:43 AM
Kishan KushwahPosted Dec 23, 2017, 7:57 AM
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
HiddenField hdfDueAmt = (HiddenField)e.Row.FindControl("hdfDueAmt");
HiddenField hdfPartyID = (HiddenField)e.Row.FindControl("hdfPartyID");
{
e.Row.BackColor = Color.FromName("#FFAAAA");// change BackGround COlor
e.Row.ForeColor = Color.FromName("#000000");// change font COlor
}
else
{
e.Row.BackColor = Color.FromName("#fff");
}
DataTable dt = DataAccess.GetData("select * from [View_PartyMaster] where [IsContact]='1' and [PartyId]='" + hdfPartyID.Value+ "' ");
if (dt != null && dt.Rows.Count > 0)
{
lblParty.Text = dt.Rows[0]["CompanyName"].ToString() + " ," + dt.Rows[0]["MemberName"].ToString() + "," + dt.Rows[0]["Phone"].ToString();
}
//if (e.Row.RowType == DataControlRowType.Header)
//{
// e.Row.BackColor = Color.FromName("#047BF8");
//}
}
Nikhil SanganiPosted Dec 23, 2017, 5:35 AM
Posted Dec 21, 2017, 3:59 AM
Ankit SharmaPosted Dec 21, 2017, 3:25 AM