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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:19:05+00:00 2026-06-07T08:19:05+00:00

I am using ASP.NET Web Forms/C# . I am using this function to fill

  • 0

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

I am using this function to fill City DropDownLists based on the selected state from State DropDownList.There are 3 DropDownLists for State and City.(Residential,Native,Office).

Here is my function.

public void CityFill(int index,int id)
{          
    var city = CustomerBLL.GetCities(index);

    //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());
        }
    }
}

This function based on the id will fill appropriate City DropDownLists based on id argument.

This is currently in code behind.My question is whether this function should be used here or should I move it to my Business Logic class.
Here is my CustomerBLL.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Drawing;
using System.Text.RegularExpressions;
using System.Data.SqlClient;
using System.Threading;
using System.Globalization;
using System.Web.Services;
using System.IO;
using System.Xml.Linq;
using System.Web.Security;
using System.Text;

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;
            }
        }
    }
}

What is a proper approach.Can anyone guide me on 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-07T08:19:07+00:00Added an answer on June 7, 2026 at 8:19 am

    Should be on your Business Logic Layer. One of the reason is that you also want to use this functionality on other forms, So, you just call it.

    The BLL would handle things that are a part of the business domain, not a part of the database, and not a part of the UI (usually). For example, using the age of a customer to determine if they qualify for a special senior’s discount. The DAL shouldn’t be doing this, it should simply be retrieving the customer data, and then storing it with the discount data after the BLL has done its work.

    1. It keeps all of your business logic localized, and in one place. Future changes will be much easier as a result.
    2. It allows you to more easily unit test your business logic. This is a big one. It’s very difficult to write automated unit tests against your business logic if this code is tightly coupled to your web page, or windows form.
    3. It keeps your UI much slimmer.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using ASP.NET Web Forms/C# . I am having this function in my
I am building a Web Application using asp.net (C#). I come from windows forms
For this question, I'm using ASP.NET Web Forms in C#, a web service and
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 using ASP.NET Web forms and sending an automated email through our SMTP
I'm using signalr in my asp.net web forms application, all seems to work good,

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.