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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:23:04+00:00 2026-06-07T00:23:04+00:00

I am using ASP.NET Web Forms/C# . I am having this function in my

  • 0

I am using ASP.NET Web Forms/C#.

I am having this function in my code behind which fills Cities DropDownList based on the State DropDownList selection.

Here is my function.

public void CityFill(int index,int id)
        {
            //This function calls GetCities method which will get all cities of a state.
            var city = CustomerBLL.GetCities(index);



            //If id=0 then clear all dropdown before filling
            //or else they get appended.
            if (id == 0)
            {
                NewCustomerddlResidentialCity.Items.Clear();
                NewCustomerddlOfficeCity.Items.Clear();
                NewCustomerddlNativeCity.Items.Clear();
                NewCustomerddlNomineeCity.Items.Clear();
            }
            else
            {
                //If 1 then clear residential city
                if(id==1)
                    NewCustomerddlResidentialCity.Items.Clear();

                //If 2 then clear Office city.
                if(id==2)
                    NewCustomerddlOfficeCity.Items.Clear();

                //If id=3 then clear Native City.
                if(id==3)
                    NewCustomerddlNativeCity.Items.Clear();

                //If id=4 then clear Nominee City
                if(id==4)
                    NewCustomerddlNomineeCity.Items.Clear();
            }

            //Loop through all the cities in st object
            foreach (var c in city)
            {
                //If id=0 then fill all dropdowns
                if (id == 0)
                {
                    NewCustomerddlResidentialCity.Items.Add(c.city_name.Trim());
                    NewCustomerddlOfficeCity.Items.Add(c.city_name.Trim());
                    NewCustomerddlNativeCity.Items.Add(c.city_name.Trim());
                    NewCustomerddlNomineeCity.Items.Add(c.city_name.Trim());
                }
                else
                {
                    //If 1 then fill Res City
                    if(id==1)
                    NewCustomerddlResidentialCity.Items.Add(c.city_name.Trim());

                    //If 2 then fill Off City
                    if(id==2)
                    NewCustomerddlOfficeCity.Items.Add(c.city_name.Trim());

                    //If 3 then fill nat city
                    if(id==3)
                    NewCustomerddlNativeCity.Items.Add(c.city_name.Trim());

                    //If 4 then fill nominee city
                    if(id==4)
                    NewCustomerddlNomineeCity.Items.Add(c.city_name.Trim());

                }
            }
        }

The arguments passed to the function are index and id.
index is SelectedIndex of State DropDownList.
id is which City DropDownList needs to be filled.

Here is BLL class

namespace CwizBankApp
{
    public class CustomerBLL
    {
        public IList<mem_city> GetCities(int index)
        {
            using (var db = new DataClasses1DataContext())
            {
                var city = db.mem_cities.Where(c => c.state_id.Equals(index)).ToList();
                return city;
            }
        }
    }
}

I need to move the function from code behind to BLL class.

How do I go about this.

Can anyone help me out with this?
Any suggestions are welcome.

  • 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-07T00:23:05+00:00Added an answer on June 7, 2026 at 12:23 am

    I would suggest not to perform that in the BLL Class. DON’T FORCE IT to BLL as is designed to seperate the data access logic from the presentation logic.

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

Sidebar

Related Questions

For this question, I'm using ASP.NET Web Forms in C#, a web service and
Using VB.NET on this one, in ASP.NET Web Forms. I have a property that
I am using ASP.NET Web Forms/C# .I am having a page Customer.aspx .I have
When developing ASP.NET websites (using VB.NET web forms) - a lot of my time
I have a ASP.NET Web Forms application and I'm using some dynamic controls in
I am working on an ASP.NET web forms application that is using Forms Authentication.
I have an ASP.NET 4 Web Forms app that is using URL Routing. I
I have an ASP.NET web application that is using forms authentication. Everything is configured
I am building a Web Application using asp.net (C#). I come from windows forms
I'm using ASP.NET Web Pages to create a form in which I can select

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.