Repeater dynamic loading Template

Source: Internet
Author: User

Recently the project used the dynamic loading template repeater, found in the garden to find A: http://www.cnblogs.com/xingshao/archive/2010/08/06/1793827.html

For reference, modify it to what you need. In this record.

 
Public class mytemplate: itemplate
{List <string> mylist; Public mytemplate (repeater RPT, list <string> List) {mylist = List; Rpt. itemdatabound + = new round (rep_itemdatabound);} public void instantiatein (control container) {htmlgenericcontrol TR = new htmlgenericcontrol ("TR"); checkbox chk = new checkbox (); chk. id = "Chk"; htmlgenericcontrol TD1 = new htmlgenericcontrol ("TD"); td1.controls. add (chk); tr. controls. add (TD1); htmlgenericcontrol td2; foreach (var str in mylist) {literal LBL = new literal (); LBL. TEXT = STR; LBL. id = "LBL _" + STR; td2 = new htmlgenericcontrol ("TD"); td2.controls. add (LBL); tr. controls. add (td2);} container. controls. add (TR);} void rep_itemdatabound (Object sender, repeateritemeventargs e) {foreach (var str in mylist) {literal LBL = (literal) E. item. findcontrol ("LBL _" + Str); LBL. TEXT = databinder. eval (repeateritem) LBL. namingcontainer ). dataitem, LBL. text ). tostring ();}}}

Background call:

 
Repwolist. itemtemplate = new mytemplate (repwolist, listtemp );
Repwolist. datasource = List; repwolist. databind ();

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.