Solved

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

Posted on 2013-05-16
2
275 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Edureka is one of the fastest growing and most effective online learning sites.  We are here to help you succeed.

911 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now