0

I am dynamically generating a table (depending on user selection from a dropdown list) with checkboxes in each cell. The user will check a few (more than 1) checkboxes and hit the start button which will send out emails with information on checkboxes selected in the dynamic table.

Currently I am not able to get the table when the button is clicked to see which checkboxes have been selected. Below is code I am using to get the dynamically generated resultsTable, but it always comes out as null.

protected void btnRequestChips_Click(object sender, EventArgs e)
        {
            login();
            string debug_output = "";
            Table chipsTable = (Table)Page.FindControl("resultsTable");
            foreach (TableRow row in chipsTable.Rows)
            {
                foreach (Table cell in row.Cells)
                {
                    foreach (Control ctrl in cell.Controls)
                    {
                        //CONTROL IS TEXBOXT: EXTRACT VALUES//
                        if (ctrl is CheckBox)
                        {
                            CheckBox chkBOx = (CheckBox)ctrl;
                            if (chkBOx.Checked)
                            {
                                debug_output += chkBOx.ID + Environment.NewLine;
                            }
                        }
                    }
                }
            }

Below is what the aspx file looks like:

<asp:Content ID="Content4" ContentPlaceHolderID="ContentBody" runat="server">
    <div class="controlContainer">
        <asp:Table id="resultsTable" BorderWidth="1" GridLines="Both" runat="server" title="Device Support"/>      
        <br />
    </div>      
</asp:Content>
user1650464
  • 121
  • 1
  • 1
  • 4

0 Answers0