使用<%#Eval(“”)%>时出错asp.net

时间:2017-12-02 04:55:29

标签: asp.net razor web webforms

您好

我收到错误<%#Eval(“ComlainnID”)%>

我在每行都有<%#Eval%>

的错误

我的GridView代码就是这个

      <asp:GridView CssClass="tbl" runat="server" AutoGenerateColumns="False" DataKeyNames="ComplainID" 
      DataSourceID="SqlDataSource1" ItemType="q" CellPadding="4" ForeColor="#333333" ID="gv" style="direction: ltr"
       OnPageIndexChanging="gv_PageIndexChanging" AllowPaging="True" EmptyDataText="No Complain Found" 
        BorderColor="Black" BorderStyle="Solid" BorderWidth="2px" PageSize="25" 
      OnDataBinding="gv_DataBinding" OnRowDataBound ="gv_DataBound" AllowSorting="True" OnRowEditing="gv_RowEditing"

      >
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        <Columns>

            <asp:ImageField  HeaderStyle-CssClass="border" HeaderText="Photo"  DataImageUrlField="ImagePath" ItemStyle-Height="50px" ItemStyle-Width="50px">
                <ItemStyle  CssClass="border"  Height="50px" Width="50px">
                </ItemStyle>
            </asp:ImageField>


             <asp:CommandField ButtonType="Button" EditText="Reply" ShowEditButton="True" 
                 HeaderStyle-CssClass="border" ItemStyle-CssClass="border" >

            </asp:CommandField>
            <asp:TemplateField>
                <ItemTemplate>

                    <asp:Label Text='<%#Eval("ComplainID")%>' ID="Label1" runat="server"></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>

        </Columns>


    </asp:GridView>

错误在线

             <asp:Label Text='<%#Eval("ComplainID")%>' ID="Label1" runat="server"></asp:Label>

错误是:

        Error   CS0246  The type or namespace name 'q' could not be found (are you missing a using directive or an assembly reference?)     

这是.NET Framework 4.6中的Web应用程序

1 个答案:

答案 0 :(得分:0)

您应该从gridview属性中删除它:

ItemType="q"