I have a GridView with records of the database.

I create two DropDown lists dynamically for each selected item. That means, if I click select, two DropDown lists appear, the first one defines a start position, the second one a stop position. Both includes numbers (depending on how many items I have selected). If I have selected 5 items, all DropBox controls include the values 1 - 5. Everything is done by code behind.

Now I want to validate that. The stop Control shall be set to a higher one as the start control. Further more, each area that is already used, is not allowed for the next controls. E. g. if I select in the first pair of DropDown lists the area 1-5, I shall not be able to choose 2-6 with the next pair of controls.

How can I do that. I thought about javascript but that could be very tricky because everything is done with code behind. The validation controls are nice, but I don't know how to validate such a complex thing...

Any Ideas?

有帮助吗?

解决方案

thank you for your answers! I dont wont to do a async postback each time, especially because the lists shouldnt be limited during the changes. I solved it in that way: The user clicks on save, I create a bool array for each dropdown item, then I loop through all dropdownlists in the placeholder. If there is a area from 3 - 5 I set the values with index 3-5 in my bool array to true. If one of these values is already true, there must be a wrong selection in the start/stop positions. I think, its not a very nice way but works pretty fast and does everything I want. If someone has a better idea, please let me know... ;)

Thanks! Stefan

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top