views:

26

answers:

1

Have a gridview control which will show X amount of rows. I want to the user to be able to select y number of rows, but limit the maximum selected rows to a set view, such as 3. If the user tries to select a fourth row I don't want them to be able to until they unselect a row.

Anyway to do this?

Thanks

A: 

Hey,

Since the GridView works with single selections, how are you allowing them to select the values in the first place, on the client or server? If on the client, you can use JavaScript to do this; simply store an array of the table rows that are selected, if the length is three, then block adding to the array until the user deselects...

Please update how you are doing it, and I can post further.

Brian
You are correct, JavaScript on the client side.
Wayne In Maine
Store a collection of the checkboxes in an array; everytime a checkbox is checked (attach to onclick of the checkbox), check the number of items checked within the array; if greater than 3, deselect one by setting checked = false;
Brian