I am puzzling with where you can place some code. I've got a listbox and also the listitems are saved within the database. The truth is, where must i put the code that retrieves the information in the database? I actually do curently have a database class having a method ExecuteSelectQuery(). Shall I create Utility class having a method public DataTable GetGroupData() ? /* group may be the listbox */ This process then calls the technique ExecuteSelectQuery() in the database class.

What must i do?

You will find many data access designs you could think about applying. A Repository pattern might enable you to get where you have to go.

The concept is to possess a GroupRepository class that brings Group data. It does not need to be excessively complicated. An easy method like GetAllGroups could return an assortment you should use for the ListBox products.

You can simply abstract the database code right into a utility class, while you suggest, which would not be a dreadful solution. (You most likely can't get far better with WebForms.) Yet when the system will finish up quite complicated, then you might like to choose a more formal architecture...

Most likely the best choice for ASP.Internet may be the ASP.NET MVC Framework, which fully replaces WebForms. It's built round the Model-View-Controller architecture pattern, that is designed particularly to obviously separate code for that interface and backened logic, which appears to become exactly what you would like. (Indeed, it can make the style of websites much more structured in lots of ways.)

Also, if you wish to produce a more structured model for the database system, think about using an ORM like the ADO.NET Entity Framework. However, this might be overkill in case your database is not very complicated. While using MVC pattern is most likely will make much more difference.

attempt to add a layer involving the UI and data access layers. There you are able to implement some type of caching when the information is not transformed frequently - by doing this you'll avoid locating multiple occasions exactly the same data in the DB.

I would suggest the Application Architecture Guide book.


Appears like you have the information access layer implemented via your database class. I suppose the confusion at this time is within applying the presentation and business layers. In my experience 'GetGroupData' is much more of an element of the Business layer and it is the best factor to implement. It will help you to make alterations in future with minimal or no impact towards the presentation layer. Therefore, the flow that you simply recommended looks right. LoadListBox then GetGroupData then ExecuteSelectQuery.