Vs.net Beta 2 using the DataGrid paging detail

Source: Internet
Author: User
datagrid| Page | Detailed in Beta 2 using the DataGrid paging
Description
1, this article only applies to beginners vs.net, especially for the vs.net environment is not very familiar with.
2, the needs of the environment: Win2000, SQL server2000, Vs.net Beta2
Steps:
1. Open Vs.net Beta 2;
2. Create a C # asp.net Web application project;

3, from the Toolbox-> data page Drag SqlDataAdapter to the Web Form design window;
Skills: Ctrl-alt-xCan quickly switch to the Toolbox interface;

4, the Data Configurator Configuration Wizard interface will appear, as follows:

5, click Next, we will begin to configure the connection with the database, because we have not previously configured
Database connection, we will create a new connection, click New Connection, here we will connect SQL Server
From the Northwind database, and extract some data from the Products table, as follows;

Note: The following establishes the database connection;


6, after the establishment of the database connection, we will read the data, here for simplicity, we
Read only the values of several fields in the Products table;


Description: Since we do not consider the modification, remove the problem, here in the advanced options we will remove the generate INSERT,
Updates and DELETE statements to update the options for the data source;

Description: The following is a picture that generates SQL statements using the Query Builder;

Note that the above steps you can not be so troublesome, you manually enter the SQL statement;

Description: Click Next, finally confirm, click Finish, complete the configuration of the SqlDataAdapter;

When you click Finish, you can see the Web Form Design window below, VS. NET creates a containing
An area of SqlDataAdapter and SqlConnection objects;

Select SqlDataAdapter1 click on the right button to view the code;

You can see the code that Vs.net built for just the steps;

7, select the SqlDataAdapter1 object, this time in the lower right corner of the property page you can see:
Configure Data adapter (C) ..., generate DataSet (G) ..., preview data (P) ...
Click to generate data set;

Description: The following window will appear, with the default settings, click to confirm will generate a dataset: dataSet11;

8, from the Toolbox-> data page Drag a DataView object to Design view;

9, select the DataView1 object, and set its properties table properties for the DataSet1 products, the following figure;

10. Drag a DataGrid object from the Toolbox->web form to the Design view;

11, set the DataSource property of DataGrid1 object is: dataView1;

12, set the DataGrid1 object AllowPaging property is: True, pagesize for each page to display the number of records, can also be modified;

13, select DataGrid1, in the property page with the following connection:

14, click: Property Builder, the following figure, in the paging settings, we modify the mode for: page number (different mode, after our pagination code writing is also different);

15, click the automatic format, you can modify the format of DATAGRID1, these are the appearance of the problem, you can choose according to their own preferences;

16, below we need to write some code;
The following figure: the mouse clicks on the red area, which is after the display of the selected object is: WebForm1, and then in the property page, click on the blue area of the button, that is the Lightning button, into the object of the event page,

17, in the WebForm1 event load on the double click the mouse, is the next figure in the dark blue place, Vs.net automatically give you add Webform1 Load event function;

Add the code in the following figure to the diagram below;

The same method increases the DataView1 PageIndexChanged event and adds the following code;

At this point, our work has been completed, press F5 Key, compiled can see the results.
Hint: Do not know is not beta2 a bug, in the code page, the following way to enter the event, it will not add this event in the list of events, but this event function, this time, you need to add it to the list of events, that is, increase the downlink code:

Above, in the Code edit page, select a function to enter, it will quickly jump to the specified function, if there is no this function, it will create this function, but the lack of this function corresponding to the event to join the event, at this time, we need to add the next figure blue highlights the region's code.

Reference sources:

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.