Solved

How Do You Insert Values Into Control Elements Inside an ASP.NET Repeater?

Posted on 2013-05-16
2
276 Views
Last Modified: 2013-06-02
I am using an ASP.NET repeater tag with linkbutton controls inside the repeater tag.  How do you insert values inside a linkbutton tag when it is inside the ASP.NET repeater elements?  I want to do this from the C# code behind the ASP.NET page.

Thanks,

Dan
0
Comment
Question by:danielolorenz
2 Comments
 
LVL 22

Accepted Solution

by:
Ivo Stoykov earned 500 total points
ID: 39173908
Hi,

You have several options.
If you bind some data (database?) use Repeater.ItemDataBound Event. It occurs after Repeater's each child is data-bound but before rendering.
in the method check the current item and set value i.e.
void Repeater1_ItemDataBound(Object Sender, RepeaterItemEventArgs e) {
  (LinkButton )e.Item.FindControl("LinkButton").Text = "desired value here";
}

Open in new window


Other option is to use Repeater.ItemCreate time to set the value

void R1_ItemCreated(Object Sender, RepeaterItemEventArgs e) {
// same as above
}

Open in new window


Finally you could use Control.PreRender. There you could set value directly
Look also Control.OnPreRender Method

HTH

Ivo Stoykov
0
 

Author Closing Comment

by:danielolorenz
ID: 39215316
Thanks for your help
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question