jquery - Asp.net/C# Get repeater row data through checkbox -


hello have repeater present data table checkbox each row, want show checked rows data 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" /></td>                                     <td><%#eval("itemdesc") %></td>                 <td><%#eval("invoicbalanceunits") %></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> 

the code behind:

protected void btnexit_click(object sender, eventargs e) {             list<repeateritem> selecteditems = rptitems.items.cast<repeateritem>().where(x => ((checkbox)x.findcontrol("cbitem")).checked).tolist();          repeater1.datasource = selecteditems;         repeater1.databind(); } 

repeater1 contain data selected through :selecteditems repeater1

 <asp:repeater id="repeater1" runat="server">     <headertemplate>         <table class="table table-bordered table-hover table-responsive table-striped table-condensed">             <tr>                                     <th>goods desc</th>                 <th>balance units</th>                                 </tr>     </headertemplate>     <itemtemplate>         <tr>                             <td><%#eval("itemdesc") %></td>             <td><%#eval("invoicbalanceunits") %></td>                  </tr>              </itemtemplate>     <footertemplate>           </table>        </footertemplate> </asp:repeater> 

when run code gives me error "itemdesc" isn't exist in repeater1, whats wrong ?

solved reference 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)) });     foreach (repeateritem item in rptitems.items)     {         if (item.itemtype == listitemtype.item || item.itemtype == listitemtype.alternatingitem)         {             checkbox checkboxinrepeater = item.findcontrol("cbitem") checkbox;              if (checkboxinrepeater.checked)             {                 datarow dr = checkeddata.newrow();                 label lblcampcode = (label)item.findcontrol("lblcampcode");                 label lblbalunits = (label)item.findcontrol("lblbalunits");                 textbox txtexitunits = (textbox)item.findcontrol("txtexitunits");                 label lblitemno = (label)item.findcontrol("lblitemno");                 label lbluom = (label)item.findcontrol("lbluom");                 label lblwt =  (label)item.findcontrol("lblwt");                 label lblcode = (label)item.findcontrol("lblcode");                 hiddenfield hfcode = (hiddenfield)item.findcontrol("hfcustomerid");                  string balunits = lblbalunits.text;                 string exituni = txtexitunits.text;                  var exituni = decimal.parse(txtexitunits.text);                 var baluni = decimal.parse(balunits);                    if (exituni > baluni)                 {                   string mystringvariable = "exit balance larger balance units!!";                   clientscript.registerstartupscript(this.gettype(), "myalert", "alert('" + mystringvariable + "');", true);                 }                 else                 {                       dr["campcode"] = lblcampcode.text;                     dr["balunits"] = lblbalunits.text;                     dr["itemnum"] =  lblitemno.text;                     dr["uom"] = lbluom.text;                     dr["wt"] = lblwt.text;                     dr["exituni"] = txtexitunits.text.trim();                      //string code = hfcode.value;                     checkeddata.rows.add(dr);                     session["checkedrows"] = checkeddata; 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -