c# - CommandName = Insert in EditTemplate of ASP.NET ListView throws "Insert can only be called on an insert item" -
i supporting web application. in that, there 2 tables - taxcode , taxrate. taxcode has 1 many relationship taxrate.
the ui has listview layouttemplate, itemtemplate , edittemplate show taxcode. when users selects tax code in edittemplate shows cutomgridview allows user create or edit tax rates particular tax code. customgridview has 3 rows each has 4 template fields shown below.
<asp:templatefield headerstyle-cssclass="highlighttitlebar" headerstyle-width="5%" headerstyle-height="30px"> <headertemplate> <custom:customimagebutton id="imgadd" runat="server" imageurl="image/add_round.gif" onclick="imgaddtaxratedetail_click" causesvalidation="false"/> </headertemplate> <itemtemplate> <custom:customimagebutton id="imgedit" runat="server" imageurl="image/edit.gif" commandname="edit" /> </itemtemplate> <edititemtemplate> <asp:imagebutton id="imgupdate" runat="server" imageurl="image/update.gif" commandname="update" /> <asp:hiddenfield runat="server" id="hfid" value='<%# bind("id") %>' /> </edititemtemplate> <footertemplate> <asp:imagebutton id="imginsert" runat="server" imageurl="image/insert.gif" commandname="insert" onclick="imginsert_click" /> </footertemplate> each row in customgridview template field. in, below image effectiveon section customgridview,

when try save taxrate proper effectiveon , rate, throws "insert can called on insert item. ensure inserttemplate has button commandname=insert." error listview doesn't have inserttemplate. record gets inserted db.
please let me know if there way resolve issue?
the error self explanatory.
take @ this: https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listview.insertitemtemplate(v=vs.110).aspx
so can either of these things.
- create insertitemplate , insert using iteminserted event of listview
- change commandname commandname="insertdata" , catch event on itemcommand
Comments
Post a Comment