Asp. NET Controls of Web

Source: Internet
Author: User
Tags datagrid example net
Asp.net|web

The Web controls makes it easy to create forms and HTML controls. For example, in the typical selection box/Select boxes in an ASP, you have to create a loop that allows the control system to load data. But in asp.net, you will have a "data-bound", which means it will connect to the data source and automatically mount the data.

These features sound fantastic, but let's examine them carefully. With traditional ASP and ADO, you can choose where to place database cursors (on the server side or on the user side), and for others, depending on the type of performance and functionality you want to create. But in asp+, you no longer have a choice. Because the link between the Web controls and the server forces you to have all the things placed on the client side. For customers and servers, it's no more than a performance center, because it has to store all of the data in local memory.

Web controls also introduces new syntax in strict XML terminology. Therefore, you will no longer have a looser code editing process, you must close all the tags, use definitions, and so on. Of course, most people are very miserable about adapting to this feature, but strict code editing usually means fewer errors.

On the other hand, the Web Forms flaw is that to use most of the functionality of the Web form, you have to use the forms post method, for example, State administration. When you use the Get method, all the best is turned off and you cannot use the corresponding function. This restriction is too unnecessary.

asp.net Server Controls

Many of the past components of the system now become ASP.net Server Controls. For example, Ad Rotator has been upgraded and started to store its information in XML, but not just that. Here is a set of control systems that can do everything from managing your form status to displaying calendars and desktops. In fact, almost every HTML element has ASP.net server Controls, which, through ASP.net server control, can interact with the programming of HTML elements. For example, you no longer need to make a detour to maintain an option selected in the ListBox. You simply instruct the listbox to operate on the server and manage it for you. More conveniently, you simply set the program, and the listbox will display the selected items in turn.

Perhaps the most interesting thing about this new controls is the DataGrid. A DataGrid is a multiple-column data-bound grid through which you can easily place data. It also provides paging, sorting, and all the functions you expect. Let's look at a DataGrid example.

Note: We will introduce the properties and methods of the DataGrid in another article.

$#@60;%@ Page language= "C #" src= "DataGrid.cs" inherits= "Sample atagridpage"%$#@62;
...

$#@60; Asp:datagrid runat=server id= "Titlesgrid" $#@62;
$#@60;/asp:datagrid$#@62;

The. aspx file above shows that it is declared without setting any properties of the DataGrid control.

DataGrid.cs:

Namespace Samples {
...

public class Datagridpage:page {
protected DataGrid Titlesgrid;

Public ICollection Gettitleslist () {

Retrieves a list of headings from the cached DataSet in application state.
DataSet Titlesdataset = (DataSet) application["Titlesdataset"];

if (Titlesdataset!= null) {
return titlesdataset.tables["Title"]. DefaultView;
}
else {
return null;
}
}

private void Loadtitlesgrid () {

Retrieving data from the database
ICollection titleslist = Gettitleslist ();

Set the data source for a control
Titlesgrid.datasource = titleslist;

and make it build its project with this data source
Titlesgrid.databind ();
}

protected override void OnLoad (EventArgs e) {
Base. OnLoad (e);

if (! IsPostBack) {

First request this page
Loadtitlesgrid ();
}
}
}
}

The loss of records is a very serious thing for programmers. In the new system, the central object is the dataset. Similar to the recordset, it is a copy of the memory stored inside the data. The dataset is central to your development, but for now, I can only say that it is close to XML, making the program relatively simple in the process of simplification and unification. You can still use what you used to deal with everything ... (except for server-side cursors) ...



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.