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

  • SEARCH
  • Home
  • 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 7708971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:44:49+00:00 2026-06-01T00:44:49+00:00

This is probably an easy solution but I can’t get my head around it.

  • 0

This is probably an easy solution but I can’t get my head around it.

I have pages that are dynamically generated, and I count the pages that need to be generated via a LINQ statement (e.g.): (THIS IS UPDATED CODE to show where the questionCount is called and set to _labelQuestionCount – this is a snippet from a larger method that dynamicaly generated all pages and set all controls in dynamic pages)

using (DataClasses1DataContext db = new DataClasses1DataContext())
{
    int questionsCount = (from q in db.vw_Custom_SelectQuestionnaireQuestions        
    select q.tbl_QuestionnaireQuestion_Description).Count();
    _labelQuestionCount = questionsCount.ToString();
}

    Label labelCount = new Label();
    labelCount.ForeColor = Color.Blue;
    labelCount.Location = new System.Drawing.Point(35, 290);
    labelCount.Size = new System.Drawing.Size(150, 30);
    labelCount.Tag = _dataSetRadioButtons.Tables["tbl_QuestionnaireAnswer_Score"];
    labelCount.Text = String.Format("Question Count: {0}", _labelQuestionCount);

Here is the global var:

   string _labelQuestionCount;

The reason for this is, as I click through the dynamically created pages, I would like to “count” them so that in my “next button” event I will know the x page is my final page and I can navigate/do some other code.

Current code for next button is: (UPdated)

        void nextButton_Click(object sender, EventArgs e)
    {  
        bool c = IsChecked(_form);

        if (c == true)
        {
            var w = Convert.ToInt32(_labelQuestionCount);
            _form.Dispose();
            w--;

            if (w == 0)
            {
                //go to another page or do something else
            }
        }
        else
        {
            MessageBox.Show("You must select at least one.");
        }
    }

As you can see I try and the the value from a global variable (e.g. __labelQuestionCount) and try and count it “down” until get to 0 and do something else.

But, because my pages are dynamically generated, I never get to 0.

This is probably the wrong way to go about this, so if anyone could suggest or help it would be greatly appreciated.

Kind regards,
geoNeo

  • 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-01T00:44:50+00:00Added an answer on June 1, 2026 at 12:44 am

    you have to reassign the decreased value(w–) to global variable _labelQuestionCount inside next button click event. because if you click on next the _labelQuestionCount will be remain same for all click.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This will probably be very easy to get a solution for, but I can't
This is blowing my mind because it's probably an easy solution, but I can't
There is probably an easy solution to this, but I can't figure it out.
This is probably easy but I am getting stuck: when I build a solution
I've been working all day and I somehow can't get this probably easy task
This is probably really easy but I can't seem to figure out how to
I have a head aching problem that I can't seem to find an easy
This is probably a pretty easy to answer question, but I can't find the
Ok I have a question and it is probably very easy but I can
This is probably an easy question, but I want to understand better how Apache

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.