Solved

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

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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!
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.

740 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