ASP.Net 2.0: Name 'Eval' is not declared

G

Guest

Hi,

The Visual Studio 2005 compiler is now giving numerous "Name 'Eval' is
not declared" errors. One example of the code the compiler objected to is:

<asp:templatefield
headertext="University ID Code"

HeaderStyle-Wrap="true"

HeaderStyle-BorderColor="White"

HeaderStyle-BorderStyle="None"

HeaderStyle-HorizontalAlign="Center"

ItemStyle-HorizontalAlign="Center"

ItemStyle-Wrap="false" >
<itemtemplate>
<asp:Label id="CSUUniversityCode"
runat="server"
Text='<%#
Eval("UniversityCode") %>'>
</asp:Label>
</itemtemplate>

This <TemplateField> is part of a bound GridView where UniversityCode is a
column name of the source table.

Thanks for your help,

Scott
 
L

Larry Bud

Hi,

The Visual Studio 2005 compiler is now giving numerous "Name 'Eval' is
not declared" errors. One example of the code the compiler objected to is:

<asp:templatefield
headertext="University ID Code"

HeaderStyle-Wrap="true"

HeaderStyle-BorderColor="White"

HeaderStyle-BorderStyle="None"

HeaderStyle-HorizontalAlign="Center"

ItemStyle-HorizontalAlign="Center"

ItemStyle-Wrap="false" >
<itemtemplate>
<asp:Label id="CSUUniversityCode"
runat="server"
Text='<%#
Eval("UniversityCode") %>'>
</asp:Label>
</itemtemplate>

This <TemplateField> is part of a bound GridView where UniversityCode is a
column name of the source table.

Hard to tell with this post, but is there a wrapping issue with your
code? The # needs to be right next to EVAL. i.e

#Eval

not
# Eval

The way your post wrapped it leads me to believe there's a space in
there.
 
G

Guest

Howdy,

Larry Bud said:
The # needs to be right next to EVAL. i.e

#Eval

not
# Eval

The way your post wrapped it leads me to believe there's a space in
there.

That's rubbish Larry :), of course you can have space inbetween. Anayway,
Slemen could you try old school style binding:

<asp:Label id="CSUUniversityCode"
runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "UniversityCode") %>'>

If it doesnt work paste everything you've got in your aspx page.

Regards
 
K

Kris Lankford

Scott,

I have never had much luck with the Eval statement by itself. Here is the
syntax I always use and haven't had trouble with it.

<%# DataBinder.Eval(Container.DataItem,"UniversityCode")%>

Kris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top