Solved

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

Posted on 2013-05-16
2
274 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
Comment Utility
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
Comment Utility
Thanks for your help
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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