looping through a checkboxlist in a repeater
Posted on 2011-09-14
In an ASP.net (C#) application, I set up a repeater to create a list of "types" of features. I've got them listed in a sql table.
Each of those "types" has a set of sub-list of features. I set up a checkboxlist in the repeater to list them all grouped by the aforementioned "type". My problem is I'm trying to use a third table to selectively check certain ones (it's not always the same ones). When the record is saved, the application puts a list of whatever was checked into this table.
The checkboxlist is repeated four times. The first three are built properly, but nothing is getting checked (there should be things). Using a Findcontrol, I always end up just checking off the items in the last iteration of that checkboxlist.
I've tried looping through rows in the repeater, but that doesn't seem to work for me as I can't seem to get my row count to work properly on databound.
The row count does work in the PreRenderComplete event, but the page hangs if I try to run the SQL query there. I take out the query and just have it count, no problem.
So, can somebody help me out? I've been tinkering with different things and I keep getting close. I just can't get over the hump.