c# - Adding multiple data from list view -


i have listview tells quantity ordered , quantity has been delivered. have complete added first row, succeeding rows not added. want add multiple records in 1 click. have add button outside list view job

here list view of form

<asp:listview id="lvpodetails" runat="server">                   <itemtemplate>                            <tr>                               <td>                                  <asp:label id="lblproduct" runat="server" type="number" text='<%# eval("refno")%>' class="form-control" visible ="false" />                                  <%# eval("productname") %>                               </td>                               <td>                                   <%# eval("price", "{0: #,###.00}") %>                               </td>                               <td><asp:textbox id="txtordered" runat="server" type="number" text='<%# eval("desiredquantity") %>'  readonly="true" class="form-control" /></td>                               <td><asp:textbox id="txtquantity" runat="server" type="number" min="1" max="1000000" text='' class="form-control" required /></td>                               <td><%# eval("poamount", "{0: #,###.00}") %></td>                               <td><%# eval("poamount", "{0: #,###.00}") %></td>                                                           </tr>                      </itemtemplate>                   <emptydatatemplate>                         <tr>                             <td colspan="4"><h2 class="text-center">no records found.</h2></td>                         </tr>                   </emptydatatemplate> </asp:listview> 

the .cs of aspx

protected void btnadd_click(object sender, eventargs e) {     bool existingsupply = isexisting();     foreach (listviewitem item in lvpodetails.items)     {         textbox quantity = (textbox)item.findcontrol("txtquantity");         label ltr = (label)item.findcontrol("lblproduct");         textbox odr = (textbox)item.findcontrol("txtordered");          string name = ltr.text;         int delivered = convert.toint32(quantity.text);         int ordered = convert.toint32(odr.text);         string status = string.empty;           if (delivered >= ordered)         {             status = "complete";          }             if (delivered < ordered)         {             status = "partially completed";          }          con.open();         sqlcommand cmd = new sqlcommand();         cmd.connection = con;         if (existingsupply)         {             cmd.commandtext = "update inventory set quantity=quantity + @quantity productid=@productid";          }          else         {             cmd.commandtext = "insert inventory values (@productid, @prodcatid, @suppliername, " +                 "@quantity, @criticallevel, @price, @status, @dateadded, @datemodified)";          }      cmd.parameters.addwithvalue("@productid", name);     cmd.parameters.addwithvalue("@prodcatid", dbnull.value);     cmd.parameters.addwithvalue("@suppliername", txtsupplier.text);     cmd.parameters.addwithvalue("@quantity", delivered);     cmd.parameters.addwithvalue("@criticallevel", dbnull.value);     cmd.parameters.addwithvalue("@price", dbnull.value);     cmd.parameters.addwithvalue("@status", dbnull.value);     cmd.parameters.addwithvalue("@dateadded", datetime.now);     cmd.parameters.addwithvalue("@datemodified", datetime.now);      //cmd.commandtext = "update purchaseorder set postatus=@postatus pono=@pono";     //cmd.parameters.addwithvalue("@postatus", status);     //cmd.parameters.addwithvalue("@pono", txtpono.text);      cmd.executenonquery();     con.close();     response.redirect("default.aspx");                          } }  

i don't it, not showing errors not adding next rows.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -