Search code examples
asp.netexpand

Asp.net expand button


I my asp.net website project with c# code, I have a table in which I generate rows programmatically. Some of those rows have expand buttons to display more information. For now, I catch the postback caused by the button, parse the name of the button that caused the postback and regenerate all my rows, adding a label to the appropriate rows with the informations that needed to be expanded.

I was wondering if there was a better way to implement a expand/collapse mechanisme that would not require me to regenerate all rows. I tried searching my tables for the rows to add the information, but since the rows are generated programmatically, the table is empty at each postback caused by the button.


Solution

  • You could have a list variable that keeps the row instances that you generated for your table. At postback, instead of generating, you iterate your list and add them in the table. At the same time, you can check, for each row, if it's the row where you need to add your information.