ListView在列表中新增一行的操作(增加、取消)
本站寻求有缘人接手,详细了解请联系站长QQ1493399855
前台:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddMeaSub2New.aspx.cs"Inherits="BQ.WebApp.DataEntry.AddMeaSub2New" MasterPageFile="~/Web.Master" %><asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"><script language="javascript" type="text/javascript" src="/js/jquery-1.4.2.min.js"></script><script language="javascript" type="text/javascript">$.fn.numeral = function() {$(this).css("ime-mode", "disabled");this.bind("keypress", function() {if (event.keyCode == 46) {if (this.value.indexOf(".") != -1) {return false;}} else {return event.keyCode >= 46 && event.keyCode <= 57;}});this.bind("blur", function() {if (this.value.lastIndexOf(".") == (this.value.length - 1)) {this.value = this.value.substr(0, this.value.length - 1);} else if (isNaN(this.value)) {this.value = "";}});// this.bind("paste", function() {// var s = clipboardData.getData('text');// if (!/D/.test(s));// value = s.replace(/^0*/, '');// return false;// });this.bind("dragenter", function() {return false;});// this.bind("keyup", function() {// if (/(^0+)/.test(this.value)) {// this.value = this.value.replace(/^0*/, '');// }// }); };</script></asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"><div class="righttop"><asp:ImageButton ID="btn_ReturnList" runat="server" ImageUrl="~/Images/b06.gif" OnClick="btn_ReturnList_Click" /></div><asp:ListView ID="ListView1" DataKeyNames="ID" runat="server" OnItemUpdating="List_ItemUpdating"OnItemEditing="ListView1_ItemEditing" OnItemDataBound="ListView_ItemDataBound"OnItemCanceling="ListView_ItemCanceling" OnItemDeleting="ListView1_ItemDeleting"OnItemInserting="ListView1_ItemInserting"><LayoutTemplate><table class="TableSub"><tr><th scope="col"><asp:Label ID="LinkButton1" runat="server" Text="二次装修补偿项目" /></th><th scope="col"><asp:Label ID="LinkButton3" runat="server" Text="数量" /></th><th scope="col"><asp:Label ID="LinkButton2" runat="server" Text="单价" /></th><th scope="col"><asp:Label ID="Label1" runat="server" Text="金额" /></th><th scope="col" id="update_Th" runat="server">修改</th><th scope="col" id="del_Th" runat="server">删除</th></tr><asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder></table></LayoutTemplate><ItemTemplate><tr><td><%#Eval("ITEM_NAME")%></td><td><%#Eval("ITEM_COUNT")%></td><td><%#Eval("UNIT_PRICE")%></td><td><font color="red"><asp:Label ID="labPriceTotal" runat="server" Text='<%#Sub2Total(Eval("ID").ToString()) %>'></asp:Label></font></td><td id="update_Td" runat="server"><asp:LinkButton ID="btn_Edit" runat="server" Text="修改" CommandName="Edit"></asp:LinkButton></td><td id="del_Td" runat="server"><asp:LinkButton ID="LinkButton4" runat="server" Text="删除" CommandName="Delete" OnClientClick="return confirm('是否确认删除?');"></asp:LinkButton></td></tr></ItemTemplate><EditItemTemplate><tr><td align="center"><asp:DropDownList runat="server" ID="ddl_item_name" /><asp:HiddenField ID="hf_item_name" runat="server" Value='<%#Eval("ITEM_NAME")%>' /></td><td align="center"><asp:TextBox runat="server" ID="tb_item_count" Text='<%#Eval("ITEM_COUNT")%>'></asp:TextBox></td><td align="center"><asp:Label runat="server" ID="tb_unit_price" Text='<%#Eval("UNIT_PRICE")%>'></asp:Label><asp:HiddenField ID="hf_price" runat="server" Value="0" /></td><td><font color="red"><asp:Label ID="labPriceTotal" runat="server" Text='<%#Sub2Total(Eval("ID").ToString()) %>'></asp:Label></font></td><td align="center"><asp:Button ID="btn_Update" runat="server" CommandName="Update" Text="确认" CssClass="btn" /> <asp:Button ID="btn_Cancel" runat="server" CommandName="Cancel" Text="取消" CausesValidation="false"CssClass="btn" /></td><td><asp:LinkButton ID="LinkButton4" runat="server" Text="删除" CommandName="Delete" OnClientClick="return confirm('是否确认删除?');"></asp:LinkButton></td></tr></EditItemTemplate><InsertItemTemplate><tr><td align="center"><asp:DropDownList runat="server" ID="ddl_item_name" /><asp:HiddenField ID="hf_item_name" runat="server" Value="请选择" /></td><td align="center"><asp:TextBox runat="server" ID="tb_item_count" Text="0"></asp:TextBox></td><td align="center"><asp:Label runat="server" ID="tb_unit_price" Text="0"></asp:Label><asp:HiddenField ID="hf_price" runat="server" Value="0" /></td><td><font color="red"><asp:Label runat="server" ID="total" Text="0"></asp:Label></font></td><td align="center"><asp:Button ID="btn_Update" runat="server" CommandName="Insert" Text="增加" CssClass="btn" /> <asp:Button ID="btn_Cancel" runat="server" CommandName="Cancel" Text="取消" CausesValidation="false"CssClass="btn" /></td><td></td></tr></InsertItemTemplate><EmptyItemTemplate></EmptyItemTemplate></asp:ListView><asp:Button ID="btnAddMea" runat="server" Text="新增" CssClass="btn" OnClick="btnAdd_Click" /><asp:Button ID="btnReport" runat="server" Text="生成报表" CssClass="btn" onclick="btnReport_Click" /><p><asp:Label ID="selectLab" runat="server"></asp:Label></p> </asp:Content>