Avatar of BOEING39
BOEING39 asked on

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
C#

Avatar of undefined
Last Comment
BOEING39

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Matthew Kelly

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
duttcom

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].
ASKER
BOEING39

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>
duttcom

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.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
ASKER
BOEING39

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:
ASKER
BOEING39

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:
ASKER
BOEING39

Here is the markup page
Home1All.aspx
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
SOLUTION
Matthew Kelly

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
BOEING39

Good information quick response.