<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>
我在构建网站时遇到以下错误...
Type 'System.Web.UI.WebControls.ImageButton' does not have a public property named 'TemplateField'
答案 0 :(得分:2)
我认为CommandArgument="<%Eval("CategoryID")%>"
需要改变
`CommandArgument="<%#Eval("CategoryID")%>"`