首页 新闻 会员 周边

获取gridview中值,fou循环直接跳出是什么原因

0
悬赏园豆:10 [已关闭问题] 关闭于 2012-07-14 15:17

    protected void btn_inset_Click(object sender, EventArgs e)     {         PurchBilling addpurchbilling = new PurchBilling();

        addpurchbilling.Supplier_id = Convert.ToInt32(ddlsupplierid.Text);         addpurchbilling.Supplier_name = txtsuppliername.Text;         addpurchbilling.PurchBilling_date = Convert.ToDateTime(txt_orderdate.Text);         addpurchbilling.Delivery_date = Convert.ToDateTime(txt_returndate.Text);         addpurchbilling.Delivery_address = txtdeliveryaddress.Text;         addpurchbilling.Delivery_phone = txtdeliveryphone.Text;         addpurchbilling.Delivery_fax = txtdeliveryfax.Text;         addpurchbilling.Delivery_zipcode = txtdeliveryzipcode.Text;         addpurchbilling.PurchBilling_id = txtpurchbillingid.Text;

        PurchBillingBLL purchbillingbll = new PurchBillingBLL();

        if (purchbillingbll.AddPurchBilling(addpurchbilling))         {             XiPurchBilling addxipurchbilling = new XiPurchBilling();

            addxipurchbilling.PurchBilling_id = txtpurchbillingid.Text;

           for (int i = 0; i<gvdata.Rows.Count; i++)               {                                addxipurchbilling.Goods_id = Convert.ToInt32(gvdata.Rows[i].Cells[0].Text.ToString());                 addxipurchbilling.Goods_name = gvdata.Rows[i].Cells[1].Text.ToString();                 addxipurchbilling.Specifications = gvdata.Rows[i].Cells[2].Text.ToString();                 addxipurchbilling.Units_of_measurement = gvdata.Rows[i].Cells[3].Text.ToString();                 addxipurchbilling.PurchBilling_number = Convert.ToInt32(gvdata.Rows[i].Cells[4].Text.ToString());                 addxipurchbilling.PurchBilling_unitprice = Convert.ToDecimal(gvdata.Rows[i].Cells[5].Text.ToString());                 addxipurchbilling.PurchBilling_price = Convert.ToDecimal(gvdata.Rows[i].Cells[6].Text.ToString());                 addxipurchbilling.Goods_barcode = gvdata.Rows[i].Cells[7].Text.ToString();                                         }             if (purchbillingbll.AddXiPurchBilling(addxipurchbilling))             {                 Response.Write("<Script>alert('添加信息成功')</Script>");             }             else                 Response.Write("<Script>alert('添加信息失败')</Script>");         }     }

 

页面:

            <asp:UpdatePanel ID="UpdatePanel2" runat="server">
            <ContentTemplate>
                  <div style="height: 300px; width: 720px;z-index: 100; left: 242px; position: absolute; top: 520px;">
                  <asp:Panel ID="Panel1" runat="server" Height="300px" Width="720px" CssClass="Panel" ScrollBars="Both">
                     <asp:GridView ID="gvdata" runat="server" AutoGenerateColumns="False" Width="696px" Height="184px" onclick="setEdit(event)" DataKeyNames="PurchBilling_id">
                      <Columns>
                          <asp:TemplateField HeaderText="选择">
                          <ItemTemplate>
                                <asp:CheckBox ID="chk_Del" runat="server" />
                          </ItemTemplate>
                          </asp:TemplateField>
                    <asp:BoundField HeaderText="货号" DataField="#">
                        <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                    </asp:BoundField>
                    <asp:BoundField HeaderText="品名" DataField="#" > 
                        <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                    </asp:BoundField> 
                    <asp:BoundField HeaderText="规格" DataField="#" >
                        <ItemStyle HorizontalAlign="Center" />
                    </asp:BoundField>
                    <asp:BoundField HeaderText="单位" DataField="#" >
                        <ItemStyle HorizontalAlign="Center" />
                    </asp:BoundField>
                    <asp:BoundField HeaderText="数量" DataField="#" >                      
                        <ItemStyle HorizontalAlign="Center" />
                    </asp:BoundField>
                    <asp:BoundField HeaderText="单价" DataField="#"   >                     
                        <ItemStyle HorizontalAlign="Center" />
                    </asp:BoundField>
                    <asp:BoundField HeaderText="金额" DataField="#">
                        <ItemStyle HorizontalAlign="Center" />
                    </asp:BoundField>
                    <asp:BoundField HeaderText="条码" DataField="#">
                        <ItemStyle HorizontalAlign="Center" />
                    </asp:BoundField>
                         <asp:TemplateField HeaderText="删除">
                          <ItemTemplate>
<%--                            <input type="button" value="delete" onclick="delRow(this)" style="left: 15px; position: relative; top: 12px;"/>
--%>                            <asp:Button ID="btnDelete" runat="server" CssClass="button1" Text="刪除" CommandName="Del" OnClientClick="return window.confirm('您確定要刪除哱')" />
                          </ItemTemplate>
                          </asp:TemplateField>
                    </Columns>
                        <EmptyDataTemplate>
                <div id="head">
                    <table style="width: 902px; height: 294px; background-color:Black;">
                        <tr>
                             <tr style="color:Silver;background-color:Black;font-weight:bold; width:5px; height:5px">
                            <td scope="col">选择</td>
                            <td scope="col">货号</td>
                             <td scope="col">品名</td>
                             <td scope="col">规格</td>
                             <td scope="col">单位</td>
                             <td scope="col">数量</td>
                             <td scope="col">单价</td>
                             <td scope="col">金额</td>
                             <td scope="col">条码</td>
                            <td scope="col">删除</td>
                       </tr>
                        <tr>
                             <tr style="background-color:Silver; width:5px; height:5px;">
                             <td scope="col"><asp:CheckBox ID="chk_Del" runat="server" /></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"><asp:Button ID="btnDelete" runat="server" CssClass="button1" Text="刪除" CommandName="Del" OnClientClick="return window.confirm('您確定要刪除哱')" /></td>
                       </tr>
                        <tr>
                             <tr style="background-color:Silver; width:5px; height:5px;">
                             <td scope="col"><asp:CheckBox ID="CheckBox1" runat="server" /></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                            <td scope="col"><asp:Button ID="Button3" runat="server" CssClass="button1" Text="刪除" CommandName="Del" OnClientClick="return window.confirm('您確定要刪除哱')" /></td>
                        </tr>
                        <tr>
                             <tr style="background-color:Silver; width:5px; height:5px;">
                             <td scope="col"><asp:CheckBox ID="CheckBox2" runat="server" /></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"><asp:Button ID="Button4" runat="server" CssClass="button1" Text="刪除" CommandName="Del" OnClientClick="return window.confirm('您確定要刪除哱')" /></td>
                       </tr>
                        <tr>
                             <tr style="background-color:Silver; width:5px; height:5px;">
                             <td scope="col"><asp:CheckBox ID="CheckBox3" runat="server" /></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                            <td scope="col"><asp:Button ID="Button5" runat="server" CssClass="button1" Text="刪除" CommandName="Del" OnClientClick="return window.confirm('您確定要刪除哱')" /></td>
                        </tr>
                        <tr>
                             <tr style="background-color:Silver; width:5px; height:5px;">
                            <td scope="col"><asp:CheckBox ID="CheckBox4" runat="server" /></td>
                            <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"><asp:Button ID="Button6" runat="server" CssClass="button1" Text="刪除" CommandName="Del" OnClientClick="return window.confirm('您確定要刪除哱')" /></td>
                       </tr>
                        <tr>
                             <tr style="background-color:Silver; width:5px; height:5px;">
                             <td scope="col"><asp:CheckBox ID="CheckBox5" runat="server" /></td>
                            <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"><asp:Button ID="Button7" runat="server" CssClass="button1" Text="刪除" CommandName="Del" OnClientClick="return window.confirm('您確定要刪除哱')" /></td>
                        </tr>
                        <tr>
                             <tr style="background-color:Silver; width:5px; height:5px;">
                             <td scope="col"><asp:CheckBox ID="CheckBox6" runat="server" /></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"></td>
                             <td scope="col"><asp:Button ID="Button8" runat="server" CssClass="button1" Text="刪除" CommandName="Del" OnClientClick="return window.confirm('您確定要刪除哱')" /></td>
                       </tr>
                    </table>
                </div>
            </EmptyDataTemplate>
                     <HeaderStyle BackColor="DimGray" Font-Bold="True" ForeColor="Black" CssClass="Freezing" BorderWidth="1px" Height="5px" Width="5px" HorizontalAlign="Center" Wrap="False" Font-Size="Medium"/>        
                     </asp:GridView>
                     </asp:Panel>
                 </div>
            </ContentTemplate>
            </asp:UpdatePanel>

我在等的主页 我在等 | 初学一级 | 园豆:140
提问于:2012-07-11 11:00
< >
分享
所有回答(1)
0

这代码能看懂?问问题的时候编辑器里有个功能叫插入代码。

水牛刀刀 | 园豆:6350 (大侠五级) | 2012-07-11 11:05
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册