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 4587992
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:51:34+00:00 2026-05-21T21:51:34+00:00

I’m fairly new to ASP and I’m a bit stumped by this. I’ve got

  • 0

I’m fairly new to ASP and I’m a bit stumped by this. I’ve got a repeater (basicInfoReport) linked to a datasource (basicInfo). This part is working fine; the Eval calls in the repeater are returning the correct data.

I’ve also got some code-behind that intends to set text in place of the <asp:Literal>s on the page. I’ve put snippets of both below.

As far as I can tell, the repeater is being databound (since the Eval calls are working), so what I can’t work out is why it’s reporting zero items, and hence, the foreach statement is doing nothing. Can anyone help? 🙂

edit: solved, see updated code even further down

ASP (irrelevant stuff removed)

<asp:AccessDataSource ID="basicInfo" runat="server" 
    DataFile="~/Disasters.accdb" 
    SelectCommand="SELECT * FROM [DisasterTable] WHERE ([ID] = ?)">
    <SelectParameters>
        <asp:QueryStringParameter Name="ID" QueryStringField="ID" Type="Int32" />
    </SelectParameters>
</asp:AccessDataSource>

<asp:Repeater ID="basicInfoReport" runat="server" DataSourceID="basicInfo" 
    onitemdatabound="basicInfoReport_ItemDataBound">
<ItemTemplate>
<h2>Disaster report: <%#Eval("Description")#%></h2>
<b><i>This report is confidential.</i></b><br /><br /><br />

This event was reported on <tt><%#Eval("dateReported")#%></tt>. It was reported  <asp:Literal ID="_wasReportedAnonymously" runat="server"></asp:Literal> and is currently  <asp:Literal ID="_isEmergency" runat="server"></asp:Literal> classed as an emergency.
</ItemTemplate>
</asp:Repeater>

C# (irrelevant stuff removed)

protected void basicInfoReport_ItemDataBound(object sender, RepeaterItemEventArgs e) {

// [...]

// reader refers to an OleDbDataReader that is used for some database interaction in this method.
// until this point, basicInfoReport has not been referenced at all.
if (reader[1].ToString().Equals("False"))
   {

     // at this point basicInfoReport.Items.Count is always zero

     foreach (RepeaterItem repeaterItem in basicInfoReport.Items) {

       // control never makes it this far

       if (repeaterItem.ItemType == ListItemType.Item || repeaterItem.ItemType == ListItemType.AlternatingItem)
          {

             Literal emergencyLiteral = (Literal)repeaterItem.FindControl("_isEmergency");

             emergencyLiteral.Text = "not";
           }
      }
   }

 // [...]

 }

Update: Worked it out thanks to almog.ori’s help. For my reference, here’s the working code:

C# (irrelevant stuff removed)

protected void basicInfoReport_ItemDataBound(object sender, RepeaterItemEventArgs e) {

// [...]

// reader refers to an OleDbDataReader that is used for some database interaction in this method.
// until this point, basicInfoReport has not been referenced at all.
if (reader[1].ToString().Equals("False"))
   {

       if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
          {

             Literal emergencyLiteral = (Literal)e.Item.FindControl("_isEmergency");

             emergencyLiteral.Text = "not";
           }
      }

 // [...]

 }
  • 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-21T21:51:35+00:00Added an answer on May 21, 2026 at 9:51 pm

    You should take a look at the msdn documentation for the ItemDataBound event, perticularly note the usage of the event argument.

          void R1_ItemDataBound(Object Sender, RepeaterItemEventArgs e) {
    
          // This event is raised for the header, the footer, separators, and items.
    
          // Execute the following logic for Items and Alternating Items.
          if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) {
    

    The event ItemDataBound hands you the “row” in the eventargs. So you can do what you like with it. You should look at e.Item.DataItem which would be the data item for the item being bound

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.
I want use html5's new tag to play a wav file (currently only supported
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms

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.