First of all, I’m using Visual Studio 2010 (Visual C#) and ASP.NET.
I’m working with a GridView that displays the current open positions at my company. I have a column of checkboxes where applicants can check off the position(s) for which they want to apply. To eliminate duplicate data, I created a linking table between my three main tables (POSITION, APPLICANT, and APPLICATION). It’s made up of just the primary keys from each of those tables, so if one person applies for 3 positions, we won’t have 3 whole applications to sift through.
I need to select the PositionID’s of the positions they selected and store them in session variables for later use.
My question is, how do I do that without knowing how many they have checked? I don’t want to just create a bunch of unnecessary variables that won’t be used. I figure I’ll have to use a foreach loop, but within the loop, I don’t know how to tell it to create a new session variable and store the ID in it.
I sure hope this question makes sense. If you need clarification, let me know.
You can just create a
List<int>or whatever datatype PositionID is and store that in the session variable.In fact, I would create a property in the control or page as
you can iterate through the list of position ids as ,
Of course, you need to grab the ids from the gridview when they want to save, or do some action. You can probably do that by looping through the gridview rows based on your implementation. Something like below.