Create a user control V.3 with a template and a user control v.3 with a template

Source: Internet
Author: User

Create a user control V.3 with a template and a user control v.3 with a template

Refactored this article "create a user control with template V.2" http://www.cnblogs.com/insus/p/4164149.html let other dynamic implementation header, Item and Footer.

Insus. NET does not want all code to be written in the switch shunting in the InstantiateIn (Control container) method. In fact, we want to use the Mediator of the Development and Design Model to split it.

 

Split into four methods:
ListItemType. Header:

ListItemType. Item:


ListItemType. AlternatingItem:


ListItemType. Footer:

 

In the above four templates, to enable dynamic columns or customize some programs, all the PlaceHolder containers are entrusted with the DataBinding event. Item and AlternatingItem share one:



OK. Now you can implement the intermediary class:

 

Now you can modify the switch program, which is the first image sample code in this article:

 
Running result:


Source code download:
Http://download.cnblogs.com/insus/Refactoring/ref_mediator_repeater.rar

 

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.