Use repeater to obtain the HTML and program it ~~

Source: Internet
Author: User

At the beginning, I tried panel and found it annoying to add a div automatically ..

 

The main principle of repeater is to put a repeater on the page, create a table manually, create a record, bind the repeater to the data, and then render the HTML, then you can program the repeater and hide it ..

 

Below we put the code up, the Code is not advanced, the key lies in the idea ~~ I used to do this in loadhtml. Yesterday I thought it would be more convenient to put it on the ASPX page ..

 

The following code is attached:

Front-end code

<% = Setpanel. outstr (this. Panel1) %>
<Asp: Panel id = "Panel1" runat = "server">
Fkjfds
</ASP: Panel>

 

<% = Settemplate. outstr (this. repeater1) %>
<Asp: repeater id = "repeater1" runat = "server">
<Itemtemplate> jjj </itemtemplate>
</ASP: repeater>

 

Class Code

Public class setpanel
{
Public setpanel ()
{
//
// Todo: add the constructor logic here
//
}
Public static string outstr (Panel PL)
{
System. Io. stringwriter Sw = new system. Io. stringwriter ();
Htmltextwriter HTW = new htmltextwriter (SW );

 

Pl. rendercontrol (HTW );
Pl. Visible = false;

Return Sw. tostring () + "pengpengmodi ";
}
}

 

Public class settemplate
{
Public settemplate ()
{
//
// Todo: add the constructor logic here
//
}

 

Public static string outstr (repeater REP)
{
System. Io. stringwriter Sw = new system. Io. stringwriter ();
Htmltextwriter HTW = new htmltextwriter (SW );

// Create a database dt
System. Data. datatable dt = new datatable ("dttest ");
DT. Columns. Add ("ID", typeof (string ));
DT. Rows. Add (new object [] {"test "});
Rep. datasource = DT;
Rep. databind ();
Rep. rendercontrol (HTW );
Rep. Visible = false;
Return "peng1" + Sw. tostring () + "Modi ";
}
}

 

 

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.