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

rahularyansharma picture rahularyansharma · Oct 12, 2011 · Viewed 9.2k times · Source
<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'

Answer

huMpty duMpty picture huMpty duMpty · Oct 12, 2011

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

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