Secondary events and detailed functions

Source: Internet
Author: User

During the development of Asp.net, many times, first, the search is performed on the webpage, and then the results are operated on other functions again. In the following example, the user clicks the button on the webpage to obtain the relevant data and then updates the data.
The result is a dataset. You can use the gridview, datalist, or repeater Data Control to display these datasets.

Create a logical class fruitcategory, which is used to communicate with data, pass in and output transactions.



Below, insus. net uses the gridview to display:



The following is the implementation of XXX. aspx. CS code, which is super simple:

 

Demo:



If you do not like the gridview control very much and are used to the Repeater control, you can look at it below. Insus. Net switched the gridview control to the Repeater control to create a webpage:


Default2.aspx. CS is similar to that of the gridview, and the value of the primary key is slightly changed.



Demo:



 
Let's look at the details and make the first record into an object for processing. Insus. Net creates a user control. However, before the creation, we should think of a problem, that is, we need to pass the data to this user control, so insus. Net has to develop an interface:



This interface has a set (object Value) method, that is, set the value for the user control.

Now you can create the row. ascx:

 

Complete the row. ascx. CS code:

 

After the row object is created, search for or load data on the webpage and dynamically Add the user control cyclically:


Xxx. aspx. CS:

 

OK. This function is demonstrated in Real Time:

 

 

Secondary events and detailed functions

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.