HtmlTable Postback Issue

G

Guest

What I'm trying to do seems pretty straightforward so I must be missing
something simple. Any help is greatly appreciated.

On my page I have a DropDownList, a HtmlTable and a Button. Each row in the
HtmlTable consists of 5 cells individually populated with a single checkbox.
The DropDownList value dictates what populates the HtmlTable. On the
SelectedIndexChanged event of the DropDownList I populate the HtmlTable based
on the DropDownList value passed to a Stored Procedure. When the Button is
clicked I would like to capture the values of each CheckBox in each of the
HtmlTables rows.

If I place the function call to populate the HtmlTable outside of my
(!IsPostBack) check everything works perfectly as long as I don't fire the
DropDownList SelectedIndexChanged event. If I fire the SelectedIndexChanged
event, I receive an error stating that "Multiple controls with the same ID
'XXXX' were found."

If I place the function call to populate the HtmlTable inside of my
(!IsPostBack) check, the SelectedIndexChanged event fires off beautifully.
Everything works fine. The HtmlTable is populated with the correct rows
reflecting the results from the Stored Procedure. The problem is that when I
click the Button to capture the values, I'm unable to access the checkbox
values. The rows to my HtmlTable (and the checkboxes) don't exist.

I assume that since I'm close to my desired results with both approaches
that it has to be something simple that I'm overlooking. Thanks for your
help.
 
E

Eliyahu Goldin

What are you doing in the ddl's SelectedIndexChanged event that you are
getting the error?

If you want to render a populated table, the best control for the is the
DataGrid. You can use TemplateColumns to put checkboxes inside the cells.
You can use ViewState to make the table persist between postbacks.
Databinding is straightforward. You would need to enable viewstate, databind
the grid once inside the (!IsPostBack) block, and then databind it again in
the ddl's SelectedIndexChanged event.


Eliyahu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

HtmlTable Postback Issue 0
htmltable\checkbox 2
Mutability issue 1
postback issue 2
Problems displaying HtmlTable on page 2
Issue with textbox script? 0
HTMLTable 1
Bind an HTMLTable to SMTPMail 2

Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,109
Latest member
JanieMalco
Top