动态创建Repeater行和删除行

  function Dels(obj) {
            var msg = "";
            msg = "你确定删除吗?";
            var trID = "rptr"+obj.id;
            if (confirm(msg) == true) {
                $("#" + trID + "").remove();
                return true;
            }
            else {
                return false;
            }
            remainTimeb();//物品添加
        }


<div id="AddressInfomationP" runat="server" class="fb" >


                    <div class="Acch3">
                        <span id="products1" style="font-weight: bold; font-size: 15px;">物品信息</span>
                        <asp:Button ID="AddProduct" runat="server" Text="添加" class="ass" OnClick="AddProduct_Click" />
                        <input type="button" id="BtnSelect" value="选择" style="display: none" class="ass" οnclick="Select()" />
                        <asp:Button ID="ButtonCP" runat="server" Text="复制票件" class="ass" OnClientClick="Seve_tab_p()" OnClick="ButtonCP_Click" />
                        <%--OnClientClick="Seve_tab_p()"--%><%--OnClientClick="Seve_tab_p()"--%>
                        <a class="boxcolse" href="javascript:close();" id="A6" style="color: #007eff;">关闭</a>
                    </div>
                    <table class="line" cellpadding="0" cellspacing="0" width="100%" border="0" style="margin-bottom: 10px;" id="tab">
                        <tr>
                            <th id="sku">SKU</th>
                            <th id="EnDes"><span class="style7">*</span>英文描述</th>
                            <th id="CNDes">中文描述</th>
                            <th><span class="style7">*</span><span id="Span15" style="font-weight: bold;">箱号</span></th>
                            <th width="7%"><span class="style7">*</span><span id="Sum" style="font-weight: bold;">数量</span></th>
                            <th width="10%"><span class="style7">*</span><span id="Q1" style="font-weight: bold;">重量</span> <span style="font-size: 10px;">(kg)/个</span></th>
                            <th width="10%" style="display: none"><span id="Span13" style="font-weight: bold;">重量</span> <span style="font-size: 10px;">(lb)</span></th>
                            <th width="9%" style="display: none"><span class="style7"></span><span id="Span17" style="font-weight: bold;">长</span> <span style="font-size: 10px;">(CM)</span></th>
                            <th width="9%" style="display: none"><span class="style7"></span><span id="Span18" style="font-weight: bold;">宽</span> <span style="font-size: 10px;">(CM)</span></th>
                            <th width="9%" style="display: none"><span class="style7"></span><span id="Span19" style="font-weight: bold;">高</span> <span style="font-size: 10px;">(CM)</span></th>
                            <th width="13%"><span class="style7">*</span><span id="Q2" style="font-weight: bold;">申报价值</span><span style="font-size: 8px;">(USD)/个</span></th>
                            <th id="Hai">海关编码 <a href="http://www.jsciq.org.cn/hsquery/hs-code-query.jsp" target="_blank" style="color: Red"></a></th>
                            <th>材质</th>
                            <th id="OP">操作</th>
                        </tr>
                        <asp:Repeater ID="RpProduct" runat="server">
                            <%--OnItemCommand="RpProduct_ItemCommand" tr id="rptr1" id="rptr<%# Container.ItemIndex + 1%>"--%>
                            <ItemTemplate>
                                <tr id="rptr<%# Container.ItemIndex + 1%>">
                                    <td>
                                        <asp:TextBox ID="TxtMaterialRefNo" Width="50" runat="server" class="atext" MaxLength="100"></asp:TextBox>
                                    </td>
                                    <td>
                                        <asp:TextBox ID="TxtEnName" runat="server" Width="50" class="atext" MaxLength="200"></asp:TextBox></td>
                                    <td>
                                        <asp:TextBox ID="TxtCnName" runat="server" Width="50" class="atext" MaxLength="200"></asp:TextBox></td>
                                    <td>
                                        <asp:TextBox ID="TxtCTN_NO" runat="server" class="ctextmin" Width="30" MaxLength="5" Style="ime-mode: Disabled"></asp:TextBox>
                                    </td>
                                    <td>
                                        <asp:TextBox ID="TxtMaterialQuantity" Width="50" runat="server" onFocus='huode(this)' class="ctext" MaxLength="30" οnblur="upadatenums2()" οnkeyup="upadatenums2()" Style="ime-mode: Disabled"></asp:TextBox></td>
                                    <td>
                                        <asp:TextBox ID="TxtWeight" runat="server" class="ctext" Width="50" MaxLength="30" onFocus='huode(this)' οnkeyup="upadatenums2()" οnblur="Conversion_T(this)" Style="ime-mode: Disabled"></asp:TextBox></td>
                                    <td style="display: none">
                                        <asp:TextBox ID="TxtWeightlb" runat="server" class="ctext" Width="50" MaxLength="30" οnkeyup="value=value.replace(/[^\d.]/g,'')" οnblur="Conversion(this)" Style="ime-mode: Disabled"></asp:TextBox></td>
                                    <td style="display: none">
                                        <asp:TextBox ID="TxtLength" runat="server" class="ctextmin" Width="20" οnkeyup="value=value.replace(/[^\d.]/g,'')" MaxLength="5" Style="ime-mode: Disabled"></asp:TextBox>
                                    </td>
                                    <td style="display: none">
                                        <asp:TextBox ID="TxtWidth" runat="server" class="ctextmin" Width="20" οnkeyup="value=value.replace(/[^\d.]/g,'')" MaxLength="5" Style="ime-mode: Disabled"></asp:TextBox>
                                    </td>
                                    <td style="display: none">
                                        <asp:TextBox ID="TxtHigh" runat="server" class="ctextmin" Width="20" οnkeyup="value=value.replace(/[^\d.]/g,'')" MaxLength="5" Style="ime-mode: Disabled"></asp:TextBox>
                                    </td>


                                    <td>
                                        <asp:TextBox ID="TxtPrice" runat="server" class="btext" Width="70" onFocus='huode(this)' MaxLength="30" οnblur="upadatenums2()" οnkeyup="upadatenums2()" Style="ime-mode: Disabled"></asp:TextBox></td>
                                    <td id="tptd1">
                                        <asp:TextBox ID="TxtCustomcCode" Width="60" runat="server" class="btext" MaxLength="200"></asp:TextBox></td>
                                    <td>
                                        <asp:TextBox ID="TxtProducingArea" Width="50" runat="server" class="btext" MaxLength="200"></asp:TextBox></td>
                                    <td>
                                        <span>
                                            <%--<asp:HiddenField ID="HiProductID" Value='<%#Eval("ProductID") %>' runat="server" />--%>
                                            <input type="button" value="删除" id="<%# Container.ItemIndex + 1%>"  οnclick="Dels(this)" />
                                           <%-- <asp:LinkButton ID="lbDel" CommandName="btndel" runat="server" OnClientClick="return Dels(rptr<%# Container.ItemIndex + 1%>)">删除</asp:LinkButton>--%></span>
                                        <span></span>


                                    </td>
                                </tr>
                            </ItemTemplate>
                        </asp:Repeater>
                    </table>
                    <div>
                        <input type="button" class="ass" value="确定" οnclick="PQD();" /></div>
                </div>


protected void AddProduct_Click(object sender, EventArgs e)
    {
        BindTa();
        DataTable dt = ViewState["Ta"] as DataTable;
        dt.Rows.Add(dt.NewRow());
        ViewState["Ta"] = dt;
        InitRpProduct(dt);
        AddressInfomationP.Attributes.Add("style", "display:block");
        //Page.RegisterStartupScript("new", "<script>showDIV()</script>");  //AddressInfomationP
    
    }


protected void BindTa()
    {
        DataTable Ta = ViewState["Ta"] as DataTable;
        for (int i = 0; i < RpProduct.Items.Count; i++)
        {
            //物品参考号
            TextBox TxtMaterialRefNo = (TextBox)RpProduct.Items[i].FindControl("TxtMaterialRefNo");
            Ta.Rows[i]["MaterialRefNo"] = TxtMaterialRefNo.Text;
            //英文描述
            TextBox TxtEnName = (TextBox)RpProduct.Items[i].FindControl("TxtEnName");
            Ta.Rows[i]["EnName"] = TxtEnName.Text;
            //中文描述
            TextBox TxtCnName = (TextBox)RpProduct.Items[i].FindControl("TxtCnName");
            Ta.Rows[i]["CnName"] = TxtCnName.Text;
            //数量
            TextBox TxtMaterialQuantity = (TextBox)RpProduct.Items[i].FindControl("TxtMaterialQuantity");
            Ta.Rows[i]["MaterialQuantity"] = TxtMaterialQuantity.Text;
            //重量
            TextBox TxtWeight = (TextBox)RpProduct.Items[i].FindControl("TxtWeight");
            Ta.Rows[i]["Weight"] = TxtWeight.Text;
            TextBox TxtWeightlb = (TextBox)RpProduct.Items[i].FindControl("TxtWeightlb");
            Ta.Rows[i]["Weightlb"] = TxtWeightlb.Text;
            长
            //TextBox TxtLength = (TextBox)RpProduct.Items[i].FindControl("TxtLength");
            //Ta.Rows[i]["Length"] = TxtLength.Text;
            宽
            //TextBox TxtWidth = (TextBox)RpProduct.Items[i].FindControl("TxtWidth");
            //Ta.Rows[i]["Width"] = TxtWidth.Text;
            高
            //TextBox TxtHigh = (TextBox)RpProduct.Items[i].FindControl("TxtHigh");
            //Ta.Rows[i]["High"] = TxtHigh.Text;
            //箱号
            TextBox TxtCTN_NO = (TextBox)RpProduct.Items[i].FindControl("TxtCTN_NO");
            Ta.Rows[i]["CTN_NO"] = TxtCTN_NO.Text;
            //申报价值/每个
            TextBox TxtPrice = (TextBox)RpProduct.Items[i].FindControl("TxtPrice");
            Ta.Rows[i]["Price"] = TxtPrice.Text;
            //海关编码
            TextBox TxtCustomcCode = (TextBox)RpProduct.Items[i].FindControl("TxtCustomcCode");
            Ta.Rows[i]["CustomcCode"] = TxtCustomcCode.Text;
            //原产地
            TextBox TxtProducingArea = (TextBox)RpProduct.Items[i].FindControl("TxtProducingArea");
            Ta.Rows[i]["ProducingArea"] = TxtProducingArea.Text;
        }
        ViewState["Ta"] = Ta;
    }
    private void InitRpProduct(DataTable dt)
    {
        
        ViewState["Ta"] = dt;
        RpProduct.DataSource = dt;
        RpProduct.DataBind();


        for (int i = 0; i < RpProduct.Items.Count; i++)
        {
            //物品参考号
            TextBox TxtMaterialRefNo = (TextBox)RpProduct.Items[i].FindControl("TxtMaterialRefNo");
            TxtMaterialRefNo.Text = dt.Rows[i]["MaterialRefNo"].ToString();
            //英文描述
            TextBox TxtEnName = (TextBox)RpProduct.Items[i].FindControl("TxtEnName");
            TxtEnName.Text = dt.Rows[i]["EnName"].ToString();
            //中文描述
            TextBox TxtCnName = (TextBox)RpProduct.Items[i].FindControl("TxtCnName");
            TxtCnName.Text = dt.Rows[i]["CnName"].ToString();
            //数量
            TextBox TxtMaterialQuantity = (TextBox)RpProduct.Items[i].FindControl("TxtMaterialQuantity");
            if (dt.Rows[i]["MaterialQuantity"].ToString() == "")
            {
                TxtMaterialQuantity.Text = "0";
            }
            else
            {
                TxtMaterialQuantity.Text = dt.Rows[i]["MaterialQuantity"].ToString();
            }
            //重量
            TextBox TxtWeight = (TextBox)RpProduct.Items[i].FindControl("TxtWeight");
            if (dt.Rows[i]["Weight"].ToString() == "")
            {
                TxtWeight.Text = "0.00";
            }
            else
            {
                TxtWeight.Text = (Convert.ToDecimal(dt.Rows[i]["Weight"].ToString())).ToString("F2");//dt.Rows[i]["Price"].ToString();
            }
            //重量bang
            TextBox TxtWeightlb = (TextBox)RpProduct.Items[i].FindControl("TxtWeightlb");
            if (dt.Rows[i]["Weightlb"].ToString() == "")
            {
                TxtWeightlb.Text = "0.00";
            }
            else
            {
                TxtWeightlb.Text = (Convert.ToDecimal(dt.Rows[i]["Weightlb"].ToString())).ToString("F2");//dt.Rows[i]["Price"].ToString();
            }
            //长
            TextBox TxtLength = (TextBox)RpProduct.Items[i].FindControl("TxtLength");
            if (HiStyle.Value == "2" || HiStyle.Value == "3")
            {
                TxtLength.Text = dt.Rows[i]["Length"].ToString();


            }
            else
            {
                TxtLength.Text = dt.Rows[0]["Length"].ToString();
            }


            //宽
            TextBox TxtWidth = (TextBox)RpProduct.Items[i].FindControl("TxtWidth");
            if (HiStyle.Value == "2" || HiStyle.Value == "3")
            { TxtWidth.Text = dt.Rows[i]["Width"].ToString(); }
            else
            {
                TxtWidth.Text = dt.Rows[0]["Width"].ToString();
            }
            //高
            TextBox TxtHigh = (TextBox)RpProduct.Items[i].FindControl("TxtHigh");
            if (HiStyle.Value == "2" || HiStyle.Value == "3")
            {
                TxtHigh.Text = dt.Rows[i]["High"].ToString();
            }
            else
            {
                TxtHigh.Text = dt.Rows[0]["High"].ToString();
            }
            //箱号
            TextBox TxtCTN_NO = (TextBox)RpProduct.Items[i].FindControl("TxtCTN_NO");
            TxtCTN_NO.Text = dt.Rows[i]["CTN_NO"].ToString();




            //申报价值/每个
            TextBox TxtPrice = (TextBox)RpProduct.Items[i].FindControl("TxtPrice");
            if (dt.Rows[i]["Price"].ToString() == "")
            {
                TxtPrice.Text = (Convert.ToDecimal("0")).ToString("F2");//dt.Rows[i]["Price"].ToString();
            }
            else
            {
                TxtPrice.Text = (Convert.ToDecimal(dt.Rows[i]["Price"].ToString())).ToString("F2");//dt.Rows[i]["Price"].ToString();
            }
            //海关编码
            TextBox TxtCustomcCode = (TextBox)RpProduct.Items[i].FindControl("TxtCustomcCode");
            TxtCustomcCode.Text = dt.Rows[i]["CustomcCode"].ToString();
            //原产地
            TextBox TxtProducingArea = (TextBox)RpProduct.Items[i].FindControl("TxtProducingArea");
            TxtProducingArea.Text = dt.Rows[i]["ProducingArea"].ToString();
        }
        HiRpProductCnt.Value = RpProduct.Items.Count.ToString();
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值