Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The name 'EVAL' does not exist in the current context

Tags:

c#

asp.net

I am adding a button in the header of the grid view but Visual Studio highlights this asn an error:

'The name EVAL does not exist in the current context'.

Why does this happen, and how can it be solved?

 <asp:gridview  runat="server" >    
      <Columns>
         .....
         <asp:TemplateField>
             <ItemTemplate>
                  <asp:Literal runat="server" ID="litFamily" Text='<%# EVAL("CompanyAddress") %>'></asp:Literal>
                </ItemTemplate>
           </asp:TemplateField>
         .....
like image 206
Sanat Pandey Avatar asked Apr 22 '12 12:04

Sanat Pandey


2 Answers

Use either

  1. <%# DataBinder.Eval(Container.DataItem, "CompanyAddress")%>
  2. <%# Eval("CompanyAddress") %>
like image 126
aleem ma Avatar answered Sep 24 '22 11:09

aleem ma


Use 'Eval' (E -> capital letter, val > small letters) in place of 'EVAL' (all capital letters)

like image 35
Waqas Avatar answered Sep 23 '22 11:09

Waqas