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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:07:12+00:00 2026-06-06T21:07:12+00:00

I am using ASP.NET Web Forms/C# .I am having a page Customer.aspx .I have

  • 0

I am using ASP.NET Web Forms/C#.I am having a page Customer.aspx.I have created CustomerBLL class in which I plan to use Linq To SQL queries to perform all database related tasks.

Consider this example.Here is a method called GetDateFormat() in my CustomerBLL class which returns Date format from database.Here is the code.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

namespace CwizBankApp
{
    public class CustomerBLL
    {
        public string GetDateFormat()
        {
            using (var db = new DataClasses1DataContext())
            {
                var format = db.CODEs.Where(code => code.NAME.Equals("dateformat")).SingleOrDefault();  
                return format.DRNAME;   
            }
        }

    }
}

From code behind I am calling this function inside of another function like this.

public void RetrieveDateFormat()
        {
            //In this function we retrieve the date format
            //from the database to identify if it is british or american


           var format = CustomerBLL.GetDateFormat();  

            //The global variable gDateFormat stores the format
           if (format != null)
           {
               Global.DateFormat = format;
           }

I am calling the function and storing the result first and then checking if it is null or not.Should I be doing this way or Should I check if it is null or not in the CustomerBLL.cs file itself?

What is better way to do this.Is my way of calling the function GetDateFormat() feasible.

Also is this approach of maintaining Linq queries in such class files and then calling them from code behind considered to be a good practice?

Can somebody tell me if I am heading in the right direction or not?

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-06T21:07:12+00:00Added an answer on June 6, 2026 at 9:07 pm

    Your way of calling the function is ok. However, you should check for null within CustomerBLL.cs.

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

Sidebar

Related Questions

I have a ASP.NET Web Forms application and I'm using some dynamic controls in
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 have an Asp.Net web page, having the common Asp.Net form. The outer border
So I have an ASP.NET/VB web application in which I'm using both RequiredFieldValidators and
I am using ASP.NET Web Forms/C# . I am having this function in my
Using VB.NET on this one, in ASP.NET Web Forms. I have a property that
When developing ASP.NET websites (using VB.NET web forms) - a lot of my time
I am working on an ASP.NET web forms application that is using Forms Authentication.
I am building a Web Application using asp.net (C#). I come from windows forms

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.