Web controls of ASP. NET (2)

Source: Internet
Author: User
Tags datagrid example

Crystal translation-yesky

Perhaps the most interesting thing about the new controls is the DataGrid. The Datagrid is a multi-column data binding grid, through which you can easily and easily
Place the data in it. It also provides paging, sorting, and other functions you want. Let's look at a Datagrid example.

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

<% @ Page language = "C #" src = "DataGrid. cs" inherits = "Samples. DataGridPage" %>
...

<Asp: DataGrid runat = server id = "titlesGrid">
</Asp: DataGrid>

The above. aspx file is displayed and declared without setting any properties of the DataGrid Control.

DataGrid. cs:

Namespace Samples {
...

Public class DataGridPage: Page {
Protected DataGrid titlesGrid;

Public ICollection GetTitlesList (){

// Retrieve the title list from the DataSet cached in the application state.
DataSet titlesDataSet = (DataSet) Application ["TitlesDataSet"];

If (titlesDataSet! = Null ){
Return titlesDataSet. Tables ["Title"]. DefaultView;
}
Else {
Return null;
}
}

Private void LoadTitlesGrid (){

// Retrieve data from the database
ICollection titlesList = GetTitlesList ();

// Set the Control Data Source
TitlesGrid. DataSource = titlesList;

// Use this data source to build its project
TitlesGrid. DataBind ();
}

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

If (! IsPostBack ){

// Request this page for the first time
LoadTitlesGrid ();
}
}
}
}

The loss of records is very serious for programmers. In the new system, the central object is Dataset. Similar to recordset
A copy of data stored in memory. Dataset is the center of your development, but now, I can only say that it is close to XML, so that the program is simple
The process of integration and unification is relatively simple. You can still use what you used in the past to handle 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.