c# - Remove row in a datatable using listview itemdeleting event -
I want to delete a line in the data table, when the user clicked the button with the item deletion event. Am I forgetting something? When I click on Linkbutton lnkdelete
, the row is still there
aspx code:
& lt; Table class = "table-table-border table-small-responsive" & gt; & Lt; Thead & gt; & Lt; TR & gt; & Lt; Th & gt; Product ID & lt; / Th & gt; & Lt; Th & gt; Product name & lt; / Th & gt; & Lt; Th & gt; Quantity & lt; / Th & gt; & Lt; Th & gt; & Lt; / Th & gt; & Lt; / TR & gt; & Lt; / Thead & gt; & Lt; Tbody & gt; & Lt; Asp: ListView id = "lvSODetails" runat = "server" onitemdeleting = "lvSODetails_ItemDeleting" & gt; & Lt; ItemTemplate & gt; & Lt; TR & gt; & Lt; Td> & Lt; Asp: label id = "lblID" runat = "server" text = '& lt;% # Eval ("ProductID")%> / & Gt; & Lt; / TD & gt; & Lt; Td> & Lt;% # Eval ("Product Name")%> & Lt; / Td> & Lt; Td> & Lt;% # Eval ("Quantity")%> & Lt; / Td> & Lt; TD & gt; & Lt; Asp: LinkButton id = "lnkDelete" runat = "server" class = "glyphicon glyphicon-remove" CommandName = "remove" /> & Lt; / TD & gt; & Lt; / TR & gt; & Lt; / ItemTemplate & gt; & Lt; EmptyDataTemplate & gt; & Lt; TR & gt; & Lt; Td colspan = "4" & gt; & Lt; H5 & gt; & Lt; Center & gt; First select a product and then click on "add product". & Lt; / Center & gt; & Lt; / H5> & Lt; / Td> & Lt; / TR & gt; & Lt; / EmptyDataTemplate & gt; & Lt; / ASP: ListView & gt; & Lt; / Tbody & gt; & Lt; / Table & gt;
C #
get zero () {lvSODetails.DataSource = SODetails; LvSODetails.DataBind (); } Secure Zero lvSODetails_ItemDeleting (Object Sender, ListViewDeleteEventArgs e) {SODetails = (DataTable) session ["sodetails"]; String lblID = (lvSodetails.Items [e.ItemIndex] .FindControl ("lblID") as the label). Text; Datarov [] drr = SODetails.Select ("Product ID =" "+ LLDID +" ''); Forward (Miscellaneous Row in Drawers); Delete (); SODetails.AcceptChanges (); GetSODetails ();}
I think you have your LinkButton
for your status.
Remove all command-related accessories and just subscribe to events that you already have.
& lt; asp: LinkButton id = "lnkDelete" runat = " Server "class =" glyphicon-glyphicon-removal "ONLYTIAM DALIAIT Ng = "lvSODetails_ItemDeleting" / & gt;
Comments
Post a Comment