C# .NET - access marquee data from database - Asked By Girish Bansal on 30-Jun-12 06:28 AM

hello dear

I am using marquee from left to right where some text shown, but i want that text should come from database.
what approach should follow to solve this solve.

Thanks in advance
Ravi Maurya replied to Girish Bansal on 30-Jun-12 06:41 AM
Make use of lable or literal control under marquee tag and give text to that control which you get from database 

like this


<marquee direction="right">
<asp:Label runat="server" ID="lblMessage" ></asp:Label>


lblMessage.Text= "Text from the database";

Try this and let me know if you face any problem.
S K replied to Girish Bansal on 30-Jun-12 06:53 AM
here is code to flashing news from database to marquee
<marquee direction="left" scrollamount="3">

<asp:Label ID="lblNews" CssClass="newsFlash" runat="server" Text=""></asp:Label>

in you code behind bind the label to database stored news as follows


cm.CommandText =

"Select NewsHeder From tblNes Where date= getdate()";

cm.CommandType =


rdr = cm.ExecuteReader();

while (rdr.Read())


lblNews.Text += rdr[0].ToString() +

" | ";



hope this helps you

Super Man replied to Girish Bansal on 30-Jun-12 01:43 PM


Try this.

In .aspx.cs page take one Public variable to store value from DB:

    public String marqueeData = "";


    protected void Page_Load(object sender, EventArgs e)


      // get your data from DB here and assign it to this variable

      marqueeData = "hello world";



Now, and in .aspx page, you can write it between marquee tag.  To get value from the DB. So you can show it in webpage


    <% =marqueeData %>



dipa ahuja replied to Girish Bansal on 30-Jun-12 04:34 PM
Take the gridview and inside the ItemTemplate use the marquee tag before the label :

  <marquee id="marquee" onmouseover="this.stop()" onmouseout="this.start()" scrolldelay="125"
  width="100%" height="12">     
     <asp:Label ID="lblName" runat="Server" Text='<%# Eval("name") %>' />