[Reprint] [tutorial] search for controls in repeater on the master page (automatic number) and construct a URL

Source: Internet
Author: User

Reprinted: http://www.cnblogs.com/thcjp/archive/2006/07/20/455489.html

I have posted
Http://thcjp.cnblogs.com/archive/2006/07/08/446076.html

The original author's words should be taken as an example
(The following code is a waste of at least four hours to come up with. In fact, the main problem is that I made a mistake in the page execution sequence, which would take so long, depressed !)

 

1 protected void Page_Load (object sender, EventArgs e)
2 {
3 Repeater rp = (Repeater) Page. Master. FindControl ("Repeater1"); // It is the first step to figure out the Repeater control.
4 rp. DataSource = dhdat; // if you want to bind the previous page, the number of items cannot be found below,
5 rp. DataBind (); // so it is important here
6
7 int coun = rp. Items. Count; // obtain the number of Repeater Items
8 for (int I = 0; I <coun; I ++) // loop all items
9 {
10 hyperlink diqu = (Hyperlink) RP. items [I]. findcontrol ("hyperlink1 ");
11 // find the hyperlink1 control, which is the word for navigation.
12 string aid = (Label) RP. items [I]. findcontrol ("label1"). Text. tostring ();
13 // because the repeater does not have a primary key, at least I don't know, so I will put another label to store the ID.
14 string url = "list. aspx? Aid = "+ aid + "";
15 // because the URL has multiple conditions, the URL is constructed here
16 if (Request. QueryString ["aid"] = null)
17 {
18 diqu. NavigateUrl = url;
19}
20 //. The specific judgments are boring.
21}
22
23
24
25}
26

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.