0

I'm checking out some of the new features in asp.net 4.5, and they don't seem available in VS 2012. Specifically, I was trying out the strongly typed data controls. VS doesn't resolve "Item" in this code block:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" 
        ModelType="WebApplication2.NorthwindService.Supplier"
        SelectMethod="GetProducts">
    <Columns>
        <asp:TemplateField HeaderText="Name">
            <ItemTemplate>                    
                <asp:Label ID="lblName" runat="server" Text='<%# Item.Name %>' />
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>

If I ignore the red squiggles, I get the following runtime error:

CS0103: The name 'Item' does not exist in the current context

Also, at the bottom of the error message, it says this:

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18034

But if I look at the project properties, under Target Framework, it says 4.5. Under the "About Microsoft Visual Studio" it says:

Microsoft .NET Framework Version 4.5.50709

Any ideas?

user2101
  • 109
  • 1

1 Answers1

2

ModelType should be ItemType. this will fix issue you are seeing. :-)

Anand
  • 1,440
  • 8
  • 11