Search code examples
asp.netgridviewimagebuttonskin

Type 'System.Web.UI.WebControls.ImageButton' does not have a public property named 'TemplateField'


<asp:GridView ID="grdCatgory" runat="server" AutoGenerateColumns="false">
    <Columns>
        <asp:BoundField DataField="Name" HeaderText="Name" />
        <asp:BoundField DataField="Description" HeaderText="Description" />
        <asp:TemplateField HeaderText="Edit">
            <ItemTemplate>
                <asp:ImageButton ID="imgEdit" runat="server" CommandArgument="<%Eval("CategoryID")%>"
                    CommandName="Edit" />
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Delete">       
            <ItemTemplate>
                <asp:ImageButton ID="imgDel" runat="server" CommandArgument="<%Eval("CategoryID")%>"
                    CommandName="Del" />
            </ItemTemplate>
        </asp:TemplateField>  

    </Columns>
</asp:GridView>

i am getting following error when build the website...

Type 'System.Web.UI.WebControls.ImageButton' does not have a public property named 'TemplateField'

Solution

  • I think CommandArgument="<%Eval("CategoryID")%>" need change to

     `CommandArgument="<%#Eval("CategoryID")%>"`