dimanche 13 novembre 2016

asp/c# print only selected items using checkbox?

I have a repeater shows items with checkbox for each item, tried to code the CheckedChanged event and successfully i got the result i want:

      <tr>
                <td><asp:CheckBox ID="cbItem" runat="server"  ClientIDMode="AutoID" AutoPostBack="True" OnCheckedChanged="cbItem_CheckedChanged"/></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>

this is the code for Checked_changed

  protected void cbItem_CheckedChanged(object sender, EventArgs e)
    {
        CheckBox chk = (CheckBox)sender;
        RepeaterItem item = (RepeaterItem)chk.NamingContainer;

        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;



        //ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + CampCode + "');", true);

    }

but if i have a print button: how to get the items selected for each item?

Aucun commentaire:

Enregistrer un commentaire