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 8311821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:56:10+00:00 2026-06-08T19:56:10+00:00

I have two GridViews. I’ve got method GetGeneralDiagnosis which returns a list of all

  • 0

I have two GridViews. I’ve got method GetGeneralDiagnosis which returns a list of all diagnosis:

CODE DIAGNOSIS
F50 Eating disorders
F51 Nonorganic sleep disorders

and method GetSpecificDiagnosis which returns more specific list:

CODE DIAGNOSIS
F50.0 Anorexia nervosa
F50.1 Atypical anorexia nervosa
F51.0 Nonorganic insomnia
F51.1 Nonorganic hypersomnia

Now I’ve got method which bind SPECIFIC DIAGNOSIS to second GridView according to GENERAL DIAGNOSIS from first GridView.

protected void gvGeneralDiagnosis_SelectedIndexChanged(object sender, EventArgs e)
{
    string generalDiagnosis = gvGeneralDiagnosis.DataKeys[gvGeneralDiagnosis.SelectedIndex].Values["ICD10Code"].ToString(); 
    var ICD10 = Visit.GetSpecificDiagnosis();   // here I'm getting data from database
    gvSpecificDiagnosis.DataSource = ICD10.Where(i => i.ICD10Code.Contains(generalDiagnosis)).Select(i => new { i.ICD10Name, i.ICD10Code });
    gvSpecificDiagnosis.DataBind();
}

I don’t want to connect to database each time selected index is changed.

How can i get my list var ICD10 = Visit.GetSpecificDiagnosis() only once? I heard that global variables are very bad idea, so how can I do that in another way?

  • 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-08T19:56:11+00:00Added an answer on June 8, 2026 at 7:56 pm

    You can use a private member variable. This one “lives” as long as the class containing it lives. Wrap it with a property to access it and automatically read it from the database, if necessary.

    private TypeOfICD10 _icd10;
    private TypeOfICD10 ICD10
    {
        get
        {
            if (_icd10 == null) { // Get from database.
                _icd10 = Visit.GetSpecificDiagnosis();   
            }
            return _icd10;
        }
    }
    

    Now you can use it like this and it will be read from the db only at the first call

    protected void gvGeneralDiagnosis_SelectedIndexChanged(object sender, EventArgs e)
    {
        string generalDiagnosis = gvGeneralDiagnosis.DataKeys[gvGeneralDiagnosis.SelectedIndex].Values["ICD10Name"].ToString();
        gvSpecificDiagnosis.DataSource = ICD10
            .Where(i => i.ICD10Code.Contains(generalDiagnosis))
            .Select(i => new { i.ICD10Name, i.ICD10Code });
        gvSpecificDiagnosis.DataBind();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two GridViews that list out included and exclude data items respectively. By
I have two gridviews in a linear layout. Here is my XML code: <LinearLayout
I have two classes (MVC view model) which inherits from one abstract base class.
I am learning ASP.NET and I have a master-detail scenario using two GridViews in
I have two GridViews layed out side by side. The first GridView contains variable
I have two GridViews. One is Source GridView and another one is Destination GridView.
I have a gridview in which i have two textboxes. The senarios is such
I have Two Labels such as FixedTotal and TotalPercent, One GridView which has One
i am using asp.net gridview in header i have two columns column select all
I have two GridViews namely GridView1 and GridView2 .They are in same Location and

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.