0

Please excuse me for a probably low quality of this question, since I'm not a web dev, so I possibly don't now some obvious things and don't know what to Google for. I think problem must have some simple solution, but I'm struggling with it for two days now, so I feel myself pretty stupid :-).

I have a custom control which is a set of checkboxes which are added dynamically based on a property which is set in OnLoad event of a page. I have two such controls on a page and second control items should be based on items selected in first control.

The problem is, I can't figure out, how to catch on autopostback which boxes were selected in first control before second contol is constructed to pass this data to it?

Petr Abdulin
  • 33,883
  • 9
  • 62
  • 96

3 Answers3

1

Take a look at this. http://forums.asp.net/t/1440174.aspx

Since your building them dynamically, they are not as easy to find as webforms would like to be, if you added them to the page and wired up events and such.

Your going to look at the Request.Forms list, and search thru it for any controls you want. I believe checkboxes are like radio buttons, they only return if they are checked, which is good, cause you want to know which ones were checked.

Yogurt The Wise
  • 4,379
  • 4
  • 34
  • 42
1

I've used same solution as in the accepted answer for this question: Dynamically Change User Control in ASP.Net , just need to assign an unique id for each dynamically created CheckBox in custom control. Not as clean solution as I want but at least it works.

Community
  • 1
  • 1
Petr Abdulin
  • 33,883
  • 9
  • 62
  • 96
0

You can save the data in the ViewState, QueryString or as Session before moving to the next page and you can do modifications based on it.

Saanch
  • 1,814
  • 1
  • 24
  • 38
  • ViewState is something I'm trying to use now, but still can't manage it out. Controls are located on same page which is 'refreshed' on each modification (e.g. box is checked). – Petr Abdulin Jul 08 '11 at 14:22