This article is from http://keyss.cnblogs.com/archive/2005/12/02/289525.htmlArticle
The main purposes of the development example website are as follows:
1. Familiar with the new. NET development environment, understand and master the built-in security authentication and implementation principles in ASP. net2.0, and master the typical website development process.
2. Explore the mature experience of multi-layer architecture development for the new. NET development environment.
3. Familiarize yourself with the new base classes in the system. Web. UI. webcontrols namespace, as well as the new page survival and control survival, and port existing controls based on. net1.0.
The overall design concept of the sample Website for development:
I. four layers of system implementation
1. Database Layer
2. Data access layer
3. Business Layer
4. Interface Layer
Among them, the first layer is basicallyCodeIt is mainly generated on demand using the codesmith template. The code and instructions generated for the link table are attached for your reference:
Friendlink.rar its interface URL is http://www.keyss.cn/admin/basismodule/home/friendlink.aspx
In the generated code. some functions need to be generated for some controls in net2.0:
for simple support of the added, modified, and deleted functions of objectdatasource, the following three functions are implemented (please note the passed parameters ):
Public Virtual int insert (friendlinkinf inf);
Public Virtual int Update (friendlinkinf inf);
Public Virtual int Delete (friendlinkinf inf );
to support pagination and cross-page sorting of the gridview control, the following two functions are implemented:
Public datatable getpage (string fieldsname, string wheresql, string orderby, int startindex, int maxrecordreturn);
Public int getrecordnumber (string fieldsname, string wheresql, string orderby, int startindex, int maxrecordreturn );
I think there may be a small bug or inconvenience in net2.0, that is, the parameters of the function for obtaining the number of records must be exactly the same as those of the function for selecting the number of records for obtaining paging data. In common sense, the parameter for obtaining the number of records must have the where condition.
the interface layer mainly uses the gridview, formview, and objectdatasource to render and edit data.
the reason why detailview is not used is that the interface style is too monotonous, although he has better support for data binding, such as displaying and parsing empty data. Sqldatasource is not used because it is too simple and violates the idea of multi-layer development. It can only be used in a simple environment for rapid development.
The following is a typical management page design interface of the sample Website:
two objectdatasource objects are displayed on a typical page, one is used to provide read-only paging data for the gridview, and the other is used to provide modifiable data for the formview control.
the two parameters in the objectdatasource control that provides data for the gridview directly reference two hiddenfields on the page, in this way, you can simply set the values of these controls for search and sorting, because objectdatasource automatically determines whether the parameters are changed.
the value of hffilter is set in the query panel, and the query panel is a template Control compiled by Alibaba Cloud. It is used to display and hide the panel of the client. The hforderby value is set in the sorting event in the gridview to achieve cross-page sorting. The Code is as follows:
protected void gvitems_sorting (Object sender, gridviewsorteventargs e)
{< br> string orderby = E. sortexpression;
If (E. sortdirection = sortdirection. descending)
{< br> orderby + = "DESC";
}< br> hforderby. value = orderby;
}
we can see that during the design process of the entire page, I have not set the appearance of the server-side controls. They all use their default no style, the result is not shown in this way, mainly thanks to ASP. with the themes function of net2.0, skin can be used to implement code and style separation just like CSS styles.