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

  • SEARCH
  • Home
  • 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 101837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:50:53+00:00 2026-05-11T00:50:53+00:00

I have a Repeater contol bound to a custom object (an EntitySpaces query) and

  • 0

I have a Repeater contol bound to a custom object (an EntitySpaces query) and have noticed there are a couple of ways to conditionally format the values being displayed.

1) From my aspx I can call a method in my code-behind and pass through the bound value and use that to drive any conditional logic:

        <a class='star' href='<%#MakePackageSelectionUrl((int)DataBinder.Eval(Container.DataItem, 'PackageId'))%>'>  and then in the code-dehind:      protected string MakePackageSelectionUrl(int packageId)     {               return string.Format('/Packages/NoAjax/ToggleStar.aspx?p={0}&amp;s={1}&amp;st={2}', packageId, _streamId, (int)_phase);     } 

2) I can hook into the ItemDataBound event, retrieve e.Item.DataItem as a DataRowView and then go crazy:

    protected void PackageList_ItemDataBound(Object sender, RepeaterItemEventArgs e)     {         if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) { return; }          DataRowView details = (DataRowView)e.Item.DataItem;          EncodePackageName(e, details);         EncodeStatusName(e);         DisplayStarImage(e, details);     }      private static void EncodePackageName(RepeaterItemEventArgs e, DataRowView dr)     {         HtmlAnchor p = (HtmlAnchor)e.Item.FindControl('packageLink');         if (p != null)         {             p.HRef = string.Format('/Packages/View.aspx?p={0}', dr['packageId']);             p.InnerHtml = HttpUtility.HtmlEncode((string)dr['packageName']);         }     } 

I’ve also noticed that using e.Item.FindControl() in the code-behind requires runat=’server’ on the control in the aspx which has a nasty habit of encoding ids and generally messing up the HTML.

I’m keen to hear from anyone that has come up with a nice approach for dealing with these sorts of issues.

  • 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. 2026-05-11T00:50:54+00:00Added an answer on May 11, 2026 at 12:50 am

    In this case all you are doing is manipulating some HTML so I would use the first method. The second method is appropriate where you need to check the item being databound and make changes to server controls in response (for example binding nested lists).

    Note also that calls to DataBinder.Eval() are expensive – it uses reflection. You will get better performance using explicit casting like so:

    MakePackageSelectionUrl(((System.Data.DataRowView)Container.DataItem)['PackageId']) 

    For reference: http://msdn.microsoft.com/en-us/library/ms998549.aspx. See section on minimising calls to DataBinder.Eval.

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

Sidebar

Related Questions

i have a repeater that is bound to a number of custom dataitems/types on
I have a Repeater control that is being bound to the result of a
I have a .NET repeater control that is data-bound to a List. As part
I have a Repeater control that loads instances of a custom control I have
I have a repeater control bound to a collection of objects. When I fire
I have a Repeater control who has its dataSource setted with a typed object
I have a repeater control in which i am showing values from database and
I would like to have a repeater control bound to method and display the
I have a repeater control that repeats a DevExpress ASPxGridView for every item bound
I have my Items table bound to the repeater control. What if I want

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.