Obtain the control in the Repeater control template Column

Source: Internet
Author: User
Directly Using repeater. findcontrol cannot obtain the sub-control, because the sub-control is actually in itemtemplate. Translate a comment:
If (roles. isuserinrole ("admin "))
{
Button Delete = (button) rptnotering. items [0]. findcontrol ("btndelete ");
Delete. Visible = true;
Button edit = (button) rptnotering. items [0]. findcontrol ("btnedit ");
Edit. Visible = true;
}

Inside a repeater are 0-Snapshot items... items [x] is where X is the index of the specific itemtemplate instance.
If your repeater returns 10 rows of data, then your repeater returns an instance of itemtemplate 10 times
And places each instance in the items [] collection.

Your findcontrol method is not looking inside the itemtemplate.
Hope this helps

The general meaning is: There are 0 items in the repeater, and items [x] is the instance for creating the template column. If your repeater has 10 rows of data, your repeater will return 10 itemtemplate instances, each instance is aggregated in the item set.

So I did it in the event, and the effect is still acceptable, but this loop does not feel very good. Also, pay attention to the above operations after the repeater data is fixed, otherwise it will not work ....

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.