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
ASKER CERTIFIED SOLUTION
Avatar of Matthew Kelly
Matthew Kelly
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of duttcom
duttcom
Flag of Australia image

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].
Avatar of BOEING39
BOEING39

ASKER

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>
Avatar of duttcom
duttcom
Flag of Australia image

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.
Avatar of BOEING39
BOEING39

ASKER

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:
Avatar of BOEING39
BOEING39

ASKER

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:
Avatar of BOEING39
BOEING39

ASKER

Here is the markup page
Home1All.aspx
SOLUTION
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of BOEING39
BOEING39

ASKER

Good information quick response.
C#
C#

C# is an object-oriented programming language created in conjunction with Microsoft’s .NET framework. Compilation is usually done into the Microsoft Intermediate Language (MSIL), which is then JIT-compiled to native code (and cached) during execution in the Common Language Runtime (CLR).

98K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo