Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6743395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:57:21+00:00 2026-05-26T11:57:21+00:00

protected void MyGrid_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { Image img

  • 0
 protected void MyGrid_RowDataBound(object sender, GridViewRowEventArgs e)
    {
    if (e.Row.RowType == DataControlRowType.DataRow)
        {
        Image img = (Image)e.Row.FindControl("Status");
            int msgid;

            int.TryParse(Convert.ToString(DataBinder.Eval(e.Row.DataItem, "MsgID")), out msgid);            
            string status = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "MessageActive"));
        if(status.Equals("No"))
        {
            e.Row.BackColor = Color.Red;
        } 
         //Based on some condition I am assigning images to the row
           if (value >= Toptarg)
            {
                img.ImageUrl = "Styles/Images/GreenBox.jpg";
                img.ToolTip = "Met Top Target";
                img.AlternateText = "Met Top Target";
            }
            else
            {
                img.ImageUrl = "Styles/Images/AmberBox.jpg";
                img.ToolTip = "In Progress";
                img.AlternateText = "In Progress";
            }

         }
      }

I have a gridView and it has a column named MessageActive, In the row databind I get the value of the messageActive. If the messageActive value is ‘Yes’ no changes are required. If it is ‘No’ I want to display the particular row in red color, How can I set the row background Color in row databound

Some properties of the grid view

   <RowStyle BackColor="White" />
   <AlternatingRowStyle BackColor="MistyRose" />
   <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
   <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
   <HeaderStyle BackColor="#696969" Font-Bold="True" ForeColor="White" />

Namespace
using System.Web.UI.WebControls;
using System.Drawing;

I am getting this error

 'Image' is an ambiguous reference between 'System.Web.UI.WebControls.Image' and 'System.Drawing.Image'

Source Error:


Line 56:         if (e.Row.RowType == DataControlRowType.DataRow)
Line 57:         {
Line 58:             Image img = (Image)e.Row.FindControl("Status");
Line 59:             int msgid;
Line 60:             int.TryParse(Convert.ToString(DataBinder.Eval(e.Row.DataItem, "MsgID")), out msgid); 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:57:22+00:00Added an answer on May 26, 2026 at 11:57 am

    Try this:

    string status = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "MessageActive"));
    if (status == "No")
    {
        e.Row.BackColor = Drawing.Color.Red
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { string[] Cardio = (string[])objDocter.getDocter_acc_prof(); if (e.Row.RowType ==
protected void GridView1_OnRowCommand(object sender, GridViewCommandEventArgs e) { int index = Convert.ToInt32(e.CommandArgument); GridViewRow row =
Page Load: protected void Page_Load(object sender, EventArgs e) { tb.Columns.Add(Id, typeof(int)); tb.Columns.Add(FileName, typeof(string)); tb.Columns.Add(FilePath,
Please take a look at this: protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { int
protected void gvdet_DataBound(object sender, GridViewRowEventArgs e) { string employeeName = dsOLDData.SelectedItem.Text; -- ERROR HERE
protected void Application_BeginRequest(object sender, EventArgs e) { const int maxFileSizeKBytes = 10240; //10 MB
protected void Button1_Click(object sender, EventArgs e) { for (int i = 0; i <
protected void Button3_Click(object sender, EventArgs e) //export { GridView2.AllowPaging = false; GridViewExportUtil.Export(Сводка.xls, this.GridView2); GridView2.AllowPaging
protected void GridView1_DataBound(object sender, EventArgs e) { GridView1.Columns[0].ItemStyle.Width = 400; <asp:GridView ID=GridView1 runat=server DataSourceID=ObjectDataSource1
protected void Button1_Click(object sender, EventArgs e) { System.Collections.ArrayList list = new System.Collections.ArrayList(); list.Add(abc); list.Add(xyz);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.