0

I am searching for a way to solve this situation:

  • I have a webforms page (.aspx) that has a table on it
  • The rows of the table are generated in the codebehind file (.vb/.cs)
  • each of these dynamic rows has a checkbox, that is added to cell 0 of each row
  • the page has a submit button, that submits the page (postback to same .aspx file)

The idea of the form is like this:

"Please select which of these rows you want to import, by checking those checkboxes"

The problem is that when I press the submit button, the values are lost, probably because the checkboxes (and table rows do not exist when the page loads). Can you suggest how to solve this scenario, so that my checkboxes can be read in the btnImport_Click event after being submitted?

Andras
  • 65
  • 6
  • Possible duplicate of [Dynamically Created Controls losing data after postback](https://stackoverflow.com/questions/17589268/dynamically-created-controls-losing-data-after-postback) – Zbyszek M. Nov 14 '17 at 14:09

1 Answers1

0

This is a common issue. Refer to earlier questions on this issue such as here.

Please try to avoid cluttering up boards with repeated questions. Think 100 years from now how over run boards like this will become if everyone just posts questions without researching first.

Community
  • 1
  • 1
Adam Heeg
  • 1,704
  • 1
  • 14
  • 34
  • Thanks @adam-heeg for the reminder, although I did search and also checked out the articles that were suggested while I wrote the question. However, I was unable to find a post that described my issue closely enough. Your suggestion did leed me to a solution, though. My checkboxes were not loaded in the page_load event, I had to take a slightly different approach. Should I update the post with that solution, or would that be clutter, as well? Thank you for the pointer! – Andras Jul 28 '15 at 14:47
  • I would suggest you post your answer if it adds to or is different than the post I referenced. I'm glad it helped. – Adam Heeg Jul 28 '15 at 14:55