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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:19:30+00:00 2026-05-26T08:19:30+00:00

I am using c# [ASP.NET 2.0 – VS 2005] and I want to implement

  • 0

I am using c# [ASP.NET 2.0 – VS 2005] and I want to implement Observer Pattern to fire a method (residing in a class) as and when DropDown index changes. There are three DropDowns and a Label Control which should display newly generated scheme code in real-time, as and when DropDown index changes.

public sealed class GetSchemeCode:INotifyPropertyChanged
{

    private string _distCode;
    private string _blockCode;
    private string _schmType;


    public string DistCode
    {
        get { return _distCode; }
        set { _distCode = value; }
    }
    public string BlockCode
    {
        get { return _blockCode; }
        set { _blockCode = value; }
    }
    public string SchemeType
    {
        get { return _schmType; }
        set { _schmType = value; }
    }


    public GetSchemeCode()
    {
        //
        // TODO: Add constructor logic here
        //
    }


    protected string GetNewSchemeCode()
    {
        SqlCommand cmdSchmCode = new SqlCommand("GenerateSchemeCode", dbConnection.cn);
        try
        {
            cmdSchmCode.CommandType = System.Data.CommandType.StoredProcedure;
            //Add Parameters
            cmdSchmCode.Parameters.AddWithValue("@districtCode", DistCode.ToString());
            cmdSchmCode.Parameters.AddWithValue("@blockCode", BlockCode.ToString());
            cmdSchmCode.Parameters.AddWithValue("@schemeType", SchemeType.ToString());
            dbConnection.OpenConnection("Scheme");
            return cmdSchmCode.ExecuteScalar();
        }
        catch (Exception)
        {
            throw;
        }
        finally
        {
            cmdSchmCode.Dispose();
            dbConnection.CloseConnection();
        }
    }

}
  • 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-05-26T08:19:30+00:00Added an answer on May 26, 2026 at 8:19 am

    Do something like the code below to hook up the Dropdown list’s selected index changed property. That is Asp.Net’s implementation of the Observer pattern behind the scenes I believe. You can set the AutoPostBack property and the Event hookup either in code or in the html markup.

    public GetSchemeCode()
    {
            DistCodeDropDownList.AutoPostBack = true;
            DistCodeDropDownList.SelectedIndexChanged += new EventHandler(DistCodeDropDownList_SelectedIndexChanged);
    
            // TODO: Hook up the other DropDownLists here. as well
    }
    
        void DistCodeDropDownList_SelectedIndexChanged(object sender, EventArgs e)
        {
            CodeOutputLabel.Text = GetNewSchemeCode();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using ASP.NET membership, if I want to get information for the current user, I
Using ASP.Net & C# I want to run my web page in the internet
Using ASP.NET 2.0 SqlMembershipProvider with MSSQL 2005. To illustrate issue : 1) Create simple
Using asp.net mvc 2 c#. I have a dynamic form. I want to get
Using Asp.net's Bind() method, how do I bind to the object itself, not one
Using ASP.NET 4.0 (c#), I want to call a button's OnClientClick event from code-behind
Using ASP.Net, VB.Net In my web page, i want to attach the file. How
Using ASP.NET MVC there are situations (such as form submission) that may require a
Using asp.net, I need to generate a snapshot of an youtube video. I have
Using ASP.net 2.0, how do I present the information to the user similar to

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.