Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 752777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:49:16+00:00 2026-05-14T14:49:16+00:00

I have a repeater control bound to a collection of objects. When I fire

  • 0

I have a repeater control bound to a collection of objects. When I fire off the button_onclick event, I need to have access to the dataitem to get the object properties. Here is what I have and my question is how do I access the underlying objects in a repeater in a button_onclick event

protected void OKButton_Click(object sender, EventArgs e)
{
    try
    {
         string selectedValue = Request.Form["repeaterRadioButton"];
        foreach (RepeaterItem item in Repeater1.Items)
        {
            if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
            {
                MyObject myObject = (MyObject)item.DataItem;
                if (!string.IsNullOrEmpty(selectedValue) && selectedValue == myObject.MyProperty)
                {
                     //stuff in here
                } ... rest of code
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T14:49:17+00:00Added an answer on May 14, 2026 at 2:49 pm

    The dataitem is not retained; it’s only used to bind the initial interface, unless you rebind the repeater on every page load. Then you need to give the button a commandname value, and tap into the repeater.itemCommand, which will give you access to the repeater item, where the dataitem property lives.

    EDIT: If you need to access items within the repeater, you can do:

    foreach (var item in this.rpt.Items)
    {
       if (item.DataItem != null) {
          //Do something
       }
    }
    

    Are you trying to access one row or the collection of rows?

    HTH.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .NET repeater control that is data-bound to a List. As part
I have a Repeater contol bound to a custom object (an EntitySpaces query) and
I have a user control in a repeater that I need to pass data
I have a Repeater control that is being bound to the result of a
I have a repeater control where in the footer I have a DropDownList. In
I have a repeater control on an ASP.NET 2.0 web form. As I understanding
I have a repeater control outputting some HTML. I want a table which outputs
I have some code that prints out databse values into a repeater control on
I have a nested Repeater control in the ItemTemplate of another Repeater. I want
I have an image gallery that is created using a repeater control. The repeater

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.