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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:55:24+00:00 2026-06-01T06:55:24+00:00

I have a ticker which uses a jquery and a Repeater.But I only get

  • 0

I have a ticker which uses a jquery and a Repeater.But I only get the last updated record of the 10 new_Feed table.This is the Source and the Code behind.

<ul id="js-news" class="js-hidden">
<li class="news-item">
    <asp:Repeater ID="Repeater1" runat="server">
    <ItemTemplate>
    <asp:Label ID="myLabel" runat="server" Text='<%# Eval("Text") %>' />
    </ItemTemplate>
    </asp:Repeater>
</li>
</ul>

 SqlConnection con = new SqlConnection(Constring);
    con.Open();
    SqlCommand cmd = new SqlCommand("select Text from News_Feed", con);

    SqlDataAdapter sqlDa = new SqlDataAdapter(cmd);
    DataTable dt = new DataTable();
    sqlDa.Fill(dt);
    Repeater1.DataSource = dt;
    Repeater1.DataBind();
    SqlDataReader reader = cmd.ExecuteReader();

    while (reader.Read())
    {
        foreach (RepeaterItem ri in Repeater1.Items)
        {

            Label lbl = ri.FindControl("myLabel") as Label;

            string Text= reader["Text"].ToString();
            lbl.Text = Text;
        }


    }
    reader.Close();
  • 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-06-01T06:55:25+00:00Added an answer on June 1, 2026 at 6:55 am

    In your code, you are binding your repeater controller with a DataTable and then doing an ExecuteReader query and looping thru the result set again. That is not needed. You need either one of those. Either the Databinding via the DataTable or the Datareader.

    So your code can be changed like this

    using(SqlConnection con = new SqlConnection(ConString))
    {
      SqlCommand cmd = new SqlCommand("select top 10 Text from News_Feed", con);
      SqlDataReader reader = cmd.ExecuteReader();
      Repeater1.DataSource = reader;
      Repeater1.DataBind();
    }
    

    and in your markup

    <asp:Repeater ID="Repeater1" runat="server">
      <ItemTemplate>
       <asp:Label ID="myLabel" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "Text")%>' />
      </ItemTemplate>
    </asp:Repeater>
    

    This should work. It is tested.

    I don’t see any jQuery code in your question. Basically the above code will load the top 10 records in the table when your page loads. You may need to update the query with an order by clause to get the correct data.

    If you really want to have some kind of dynamically updating news ticker ( without reloading the page), you should use jQuery to do that. Load your content initially, then using javascript setInterval function do execute an ajax call in every n seconds and reload the news ticker with the data received from the ajax call.

    Here is a simple, but working example for loading content dynamically using jQuery ajax.

    Have a div in your page to show the data

    <div id="divNews"></div>
    

    Add the below script to your page

    <script type="text/javascript">
    
        $(function () {
            function GetNewsItems() {
                $("#divNews").load("newsfeed.ashx");
            }
            setInterval(function () { GetNewsItems() }, 5000);
        });
    
    </script>
    

    So the above script is using setInterval function to execute the GetNewsITems function to load the data every 5 seconds.It calls a file called newsfeed.ashx for the data
    So create a generic handler caleld newsfeed.ashx and replace the code in ProcessRequest method with the below one

    public void ProcessRequest(HttpContext context)
    {
          context.Response.ContentType = "text/plain";
          StringBuilder str = new StringBuilder();
          str.Append("<ul>");
          using (SqlConnection con = new SqlConnection(ConString))
          {
                SqlCommand cmd = new SqlCommand("select Text from News_Feed ORDER BY ID DESC", con);
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                 {
                   str.Append("<li>"+reader.GetString(0)+"</li>");
                 }
           }
           str.Append("</ul>");
           context.Response.Write(str.ToString());
     }
    

    The generic handler will return the markup of a UL element with 10 items from the table. we are loading this content in to the div using the jQuery load method.

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

Sidebar

Related Questions

I have a .swf file, which I have to display as a ticker, but
I have a ticker which items are updated using polling. I have written a
I have an ASP .NET web application which uses Forms Authentication. Let's call this
I have a table which has the below columns. Ticket_id (Primary key, Int) Attachment1
I have setup a basic application which uses the ActiveDirectoryMembershipProvider to talk to our
I need to make some changes to this news ticker which is based on
I have a Screen base class from which all other Screens extend. Within this
I have this global variable which is used as counter which I want to
I have some jQuery going here: $('#ticker1').hide(); $('#ticker2').hide(); $('#ticker3').hide(); $(#ticker).oneTime(2000,function(i) { /* Do the
I have this application that uses custom methods to register and loggin users using

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.