asp.net - asp:c# Print checked rows using checkbox -


i want print selected rows in repeater table when button clicked, .aspx code:

    <asp:repeater id="rptitems" runat="server">         <headertemplate>             <table class="table table-bordered table-hover table-responsive table-striped table-condensed">                  <tr>                     <th> </th>                     <th>goods desc</th>                     <th>balance units</th>                     <th>exit units</th>                 </tr>         </headertemplate>          <itemtemplate>             <tr>                 <td><asp:checkbox id="cbitem" runat="server"  clientidmode="autoid" autopostback="true" /></td>                  <td><asp:label runat="server" id="lblcampcode" text='<%#eval("itemdesc") %>'></asp:label></td>                  <td><asp:label id="lblbalunits" runat="server" text='<%#eval("invoicbalanceunits") %>'></asp:label> </td>                  <td><asp:textbox id="txtexitunits" runat="server"></asp:textbox>                     <asp:regularexpressionvalidator id="revunits" runat="server" display="dynamic" controltovalidate="txtexitunits" validationexpression="^\d+$" errormessage="please, insert number." cssclass="text-danger"></asp:regularexpressionvalidator>                     <asp:requiredfieldvalidator id="rfvunits" runat="server" display="dynamic" controltovalidate="txtexitunits" errormessage="insert number of units." cssclass="text-danger"></asp:requiredfieldvalidator>                       </td>               </tr>            </itemtemplate>           <footertemplate>               </table>            </footertemplate>        </asp:repeater>       <asp:button id="btnexit" runat="server"  text="exit now" onclick="btnexit_click" /> 

and .cs code button click event loop ever checked item in repeater, , retrieve checked rows data:

   protected void btnexit_click(object sender, eventargs e)     {         foreach (repeateritem item in rptitems.items)         {             if (item.itemtype == listitemtype.item || item.itemtype == listitemtype.alternatingitem)             {                 checkbox checkboxinrepeater = item.findcontrol("cbitem") checkbox;                  if (checkboxinrepeater.checked)                 {                     label lblcampcode = (label)item.findcontrol("lblcampcode");                     label lblbalunits = (label)item.findcontrol("lblbalunits");                     textbox txtexitunits = (textbox)item.findcontrol("txtexitunits");                     string campcode = lblcampcode.text;                     string balunits = lblbalunits.text;                     string exituni = txtexitunits.text;                  }             }         }      } 

i think should use datatable store data.

i solve using datatable this:

 datatable checkeddata = new datatable();         checkeddata.columns.addrange(new datacolumn[6] { new datacolumn("campcode"), new datacolumn("balunits", typeof(decimal)), new datacolumn("exituni",typeof(decimal)), new datacolumn("itemnum"), new datacolumn("uom"), new datacolumn("wt", typeof(decimal)) });  dr["campcode"]=lblexitunits.text; //and on datarow dr = checkeddata.newrow(); 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -