Postback question

  • Thread starter Thread starter Steve Black
  • Start date Start date
S

Steve Black

I dynamically create a table (System.Web.UI.WebControls.Table) and
load it with various radiobuttons and text.

I have a 'Submit' button on my page (another server-side button, not
an HTML Submit button). When I click the submit button, I want to see
which radio button was selected.

The problem is, when I check the number of controls in my table (by
looping through the rows) in the code-behind for the Submit button, I
am being told that there are no rows in my table. I'm pretty sure
this is because the Page_Load runs prior to the Submit code, and I
therefore am losing all of my table information.

How can I access my table information before it get wiped out by the
Postback?

Any help would be greatly appreciated.

Thanks,

Steve
 
Actually, you need to rebuild your table upon each postback. But don't
re-initialize the values of your radio buttons, let ASP.NET do that for you
so that you can access the values that the user picked.
 
Call the dynamic control create method in the init method. So you won't face
any problems when doing a postback.

HTH
 
Thanks guys,

Actually, it sounds like I have a little bit of a rewrite to do, because
I don't currently create my table when the page loads.

I have a datagrid on my page and each "row" in my grid has a 'Select'
button. The dynamically-created table depends on the selection of the
datagrid. From there the user has the option to make specific choices
(radiobuttons within my table) and I need to commit those selections to
the database.

So, I cannot just automatically create my table when the page loads
because I don't know which table to load until the user selects the
appropriate datagrid item.

Any ideas now?

Thanks again,

Steve
 
Back
Top