I have a repeater shows items with checkbox for each item, i have a button that will print only the selected rows, but how to save the checked rows as a datatable or something like that:
this is the .aspx :
- <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 a 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>
and this is the button event :
- 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") as 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 want to save the CampCode,BalUnits,ExitUni, for each row checked ?