Gridview Code Behind

I am attempting to modify the attached code behind to highlight text under a given condition.  I am not getting an error but the code for GridView #2 is not working.   Help would be appreciated.
Home1All.aspx.cs
BOEING39Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Matthew KellyCommented:
Is the event on the GridView in the markup page? ie. in the Home1All.aspx page:

<asp:GridView id="GridView2" OnRowDataBound="GridView2_RowDataBound" />

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
duttcomCommented:
At the risk of suggesting the obvious, is 12 the correct cell/column number? i.e.

e.Row.Cells[12] refers to the 13th column in the GridView, given that the first cell/column would be e.Row.Cells[0].
0
BOEING39Author Commented:
I changed the markup code to this and I am receiving this message:

************************************************************************

Compiler Error Message: CS0117: 'ASP.homepage_home1all_aspx' does not contain a definition for 'GridView2_RowDataBound'

Source Error:


 

Line 314:
Line 315:
Line 316:                <asp:GridView ID="GridView2" onrowdatabound="GridView2_RowDataBound" runat="server" AutoGenerateColumns="False"
 

**************************************************************************

 <asp:GridView ID="GridView2" onrowdatabound="GridView2_RowDataBound"   runat="server" AutoGenerateColumns="False"  
                    BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px"
                    CellPadding="4" DataKeyNames="ID" DataSourceID="SqlDataSource2"  
                    EnableModelValidation="True" ForeColor="Black" GridLines="Horizontal"
                    style="font-size: small">
                    <Columns>
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

duttcomCommented:
Your code says-

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e),

not
 
protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)

Given that your gridview is GridView2 and not 1 as per the code.
0
BOEING39Author Commented:
The columns are correct.   After inserting the On row data bound into the Markup page when refreshing I am now receiving the following error:


Compilation Error
  Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

 Compiler Error Message: CS0542: '_Home1All': member names cannot be the same as their enclosing type

Source Error:


 

Line 189:
Line 190:
Line 191:    partial class _Home1All : System.Web.UI.Page
Line 192:    {
Line 193:
0
BOEING39Author Commented:
Please look at the markup page there are two Gridview.  I was missing the OnRowdatabound event but it is there now.   The problem now seems to be with the code behind.


Compiler Error Message: CS0542: '_Home1All': member names cannot be the same as their enclosing type

Source Error:


 

Line 189:
Line 190:
Line 191:    partial class _Home1All : System.Web.UI.Page
Line 192:    {
Line 193:
0
BOEING39Author Commented:
Here is the markup page
Home1All.aspx
0
Matthew KellyCommented:
Change

partial class _Home1All2 : System.Web.UI.Page
    {

        protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
        {

            if (e.Row.RowType == DataControlRowType.DataRow)
                if (e.Row.Cells[5].Text == "Serviceable" || e.Row.Cells[5].Equals(DBNull.Value))
                {
                    e.Row.BackColor = System.Drawing.Color.Green;
                }

        }

    }

Open in new window


To just:

        protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
        {

            if (e.Row.RowType == DataControlRowType.DataRow)
                if (e.Row.Cells[5].Text == "Serviceable" || e.Row.Cells[5].Equals(DBNull.Value))
                {
                    e.Row.BackColor = System.Drawing.Color.Green;
                }

        }

Open in new window

0
BOEING39Author Commented:
Good information quick response.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.