We are developing a project in ASP.NET/C#
which is a not a very large project but a sizeable one. Currently we have developed few pages. I am talking from point of view of a single page right now.The approach is followed for every pages that has been developed so far.
In the code behind of my page we use Linq To SQL
queries directly. The insert operation
is done , queries
to fill dropdownlists
and other database
related operations are used in code behind itself.
We use functions though.The same goes for other pages as well.
My question is should I include them in class
files and then create objects
and call appropriate methods to do my stuff?
If yes, should we create a single class
or create one class per page. Is this called creating Data Access Layer
.
Can anyone help me suggest a proper way to do this?
Is this approach a good programming practice.
This is a simple function that we are using in our code behind
public void AccountTypeFill()
{
//Get the types of Account ie Entity and individual
var acc = from type in dt.mem_types
select type.CustCategory;
if (acc != null)
{
NewCustomerddlAccountType.DataSource = acc.Distinct().ToList();
NewCustomerddlAccountType.DataBind();
}
}
Can anyone point a simple example referring to this query?
I hope my question makes sense. Any suggestions are welcome.