In those years, I was still studying asp.net (I) study notes.

Source: Internet
Author: User

These years have basically learned the basic knowledge of the front-end, and the fourth class in those years is asp.net. Of course, at that time, I read many tutorials, such, of course, things have been mentioned in many things, such as object-oriented and C # knowledge. Since C ++ was used at the time, I didn't read this, but I started to read it directly from asp.net, I mainly want to learn some basic controls used by asp.net, and then I don't want to read them anymore. I started to learn the data tutorial of asp.net (scott tutorial), and gradually went to web development in those years.

Let's take a look at the use of some basic controls in asp.net.

I. Use of the GridView Control

1. GridView is a data control in asp.net. when data is displayed, it is displayed as a table on the page)

2. By default, GridView uses asp: boundField to bind data. Of course, there are other binding controls, and commandField specifies the command

3. The GridView is a template-supporting control. The TemplateField in Columns mainly contains projects, edits, pages, headers, etc. After the template is specified, the template is displayed in the cells of the table.

Example (the Northind database is used below)

 

Ii. Use of the FormView Control

1. FormView is a template control. A template is automatically created when it is added. You can set the data display mode through EditItemTemplate, InsertItemTemplate, ItemTemplate, and so on.

2. FormView only displays one piece of data in the record. The default value is the first one. The paging function can be enabled.

3. display the data in a table in html displayed in the browser. You can view the source code of the statement in the browser.

Example

 

Iii. Use of the DetailsView Control

1. DetailsView displays only one data record at a time. You can edit and delete this data record at the same time.

2. The display of DetailsView on the page is also in the form of a table.

3. DetailsView also supports templates. You can design the display styles. In fields, you must finish the fields to produce results.

Example

 

Iv. Use of the ListViewr Control

1. template control. It is necessary to specify the placeholder ID.

2. The display on the page is not displayed as a pure template.

3. pagination is not supported. DataPager can work with it to implement pagination.

Sample Code:

<asp:ListView ID="ListView1" runat="server" DataSourceID="ListViewdata" ItemPlaceholderID="demo"><LayoutTemplate><asp:PlaceHolder ID="demo" runat="server"></asp:PlaceHolder><asp:DataPager ID="DataPager1" runat="server" PageSize="10"><Fields><asp:NextPreviousPagerField ButtonType="Link" ShowFirstPageButton="True" ShowLastPageButton="True" /></Fields></asp:DataPager></LayoutTemplate><ItemTemplate><div><%#Eval("TerritoryID")%></div></ItemTemplate></asp:ListView>

 

V. Use of the repeater control

Repeater is a template-only control. developers can deploy their own data display methods, including Header templates, item templates, and script templates. rereapter repeatedly displays the read data, one disadvantage is that pagination is not allowed. Of course, this can also be solved. It can be used with the three-party control aspnetpager to implement pagination, which was previously used in projects; I remember an example of repeater nesting while reading scott's tutorial. It took a long time to understand it. The following is an example of using it:

 

This figure is a bit difficult with the above figure. It is mainly because there is no database, so you know it, huh, huh.

6. Three-layer structure

Anyone who has read scott's tutorial knows that we will first create a data access layer, a business logic layer, and a presentation layer. The next figure is shown, I think everyone has seen it:

 

(Screenshot taken from scott tutorial)

So let's look at the functions of each layer:

DAL layer: used to access databases and perform CRUD operations on data. The technology used may be ADO. NET or some entity frameworks.

BLL layer: This layer is used to meet business requirements and some system requirements. This is also the most complicated because the requirements are constantly changing. If there is no good code specification, it will be very troublesome to change. Read data from the DAL layer, process the data, and then deliver the data to the presentation layer.

GUI layer: Simply put, it is to display data. If you consider the user experience, this layer is not so easy to do, at least the programmer is not easy to do, just hand it over to the artist.

The advantage of a three-tier structure is that when the database or performance Layer needs to be modified, you only need to modify one layer. For example, the database is changed from SQL server to MySQL (or Oracle ), the data access layer should be changed. The shortcomings are also obvious. If a field is changed in the database table, each layer will be modified. In addition to the three-layer structure, there are also multi-layer structures, which are more detailed, such as the entity layer and Ajax layer.

Summary

I have read two tutorials and several books on asp.net in those years (for example, revealing asp. net3.5). Later, I went to 4.0 and learned about it. Finally, I found that when I was working on a project, I used a relatively mature technology to complete it. This article will recall the days when I started learning asp.net in those years.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.