Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8130703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:49:16+00:00 2026-06-06T08:49:16+00:00

First of all, I’m using Visual Studio 2010 (Visual C#) and ASP.NET. I’m working

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T08:49:18+00:00Added an answer on June 6, 2026 at 8:49 am

    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

    public List<int> SelectedPositionIDList
    {
       get
       {
            if(Session["SelectedPositions"] != null)
              return Session["SelectedPositions"] as List<int>;
            return new List<int>();
       }
       set
       {
          Session["SelectedPositions"] = value;
       }
    }
    

    you can iterate through the list of position ids as ,

    foreach(int positionId in SelectedPositionIdList)
    {
       //Do something.
    }
    

    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.

    List<int> positions = new List<int>();
    
    foreach(GridviewRow row in gdPositions)
    {
        CheckBox cb = row.FindControl("checkbox") as CheckBox;
        if(cb != null && cb.Checked)
          positions.Add(/*find position id from row here*/);
    }
    
    if(positions.Count > 0)
        Session["SelectedPositionIdList"] = positions;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First of all, I'm really new to the MVC Asp.Net ideology. I would like
First of all, I'm using Windows, just to make that clear. I am using
First of all, I'm using KohanaPHP Framework. I've impletemented SWFUpload successfully, working quite nice.
first of all, sorry if that question is dumb but I´m a total newbie
First of all, before I begin, I am using VC++ 2008 professional, running an
First of all, let me clarify that I know you cannot have actual abstract
First of all, I got this huge xml file that represents data collected by
First of all I agree that mocking external API calls is the right thing
First all, I am still learning CakePHP and I am close to ZERO using
First of all Im new to vb 2010 and so far have enjoyed what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.