How To Display data in marquee from database by using asp.net c#

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Marquee.aspx.cs" Inherits="Marquee" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
   <title>Untitled Page</title>
</head>
<body>
   <form id="form1" runat="server">
       <div>
           <marquee id="ml" style="text-align: center" direction="up" width="195" height="170"
               scrolldelay="20" scrollamount="1">
               <asp:Repeater ID="Repeater1" runat="server">
                   <ItemTemplate>
                       <br />
                       <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("URL") %>'>
                           <asp:Label ID="Label1" runat="server" Text='<%# Eval("Desc") %>'></asp:Label></asp:HyperLink><br />
                   </ItemTemplate>
               </asp:Repeater>
           </marquee>
       </div>
   </form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Marquee : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Repeater1.DataSource = GetData();
            Repeater1.DataBind();
        }

    }
    public DataSet GetData()
    {
        DataSet ds = new DataSet();
        DataTable dt = new DataTable("News");
        DataRow dr;
        dt.Columns.Add(new DataColumn("Id", typeof(Int32)));
        dt.Columns.Add(new DataColumn("Url", typeof(string)));

        dt.Columns.Add(new DataColumn("Desc", typeof(string)));
        for (int i = 1; i <= 10; i++)
        {
            dr = dt.NewRow();
            dr[0] = i;
            dr[1] = "URL" + i.ToString();

            dr[2] = "Description " + i.ToString();
            dt.Rows.Add(dr);
        }
        ds.Tables.Add(dt);
        Session["dt"] = dt;
        return ds;
    }
}

16 comments:

  1. thank you for sharing your knowledge with everyone.

    i recently become familiar to asp .net
    i bind the data to datasource in design view through wizard also form tables in database explorer in wizard .so whats the difference between the one i implement and binding on page
    -load(in your links)
    I will really be grateful if you throw some light on it

    my email id is
    sunrise_06@yahoo.com

    ReplyDelete
  2. thank u so much this is what i was looking for...

    ReplyDelete
  3. thank you for sharing your knowledge with everyone.

    ReplyDelete
  4. thanks alot
    it really helpd us

    ReplyDelete
  5. thanks for sharing such a wonderful script........

    ReplyDelete
  6. greate thanks...

    ReplyDelete
  7. how to use xmldatascource along with repeater control

    ReplyDelete
  8. thanks that is what i want.

    ReplyDelete
  9. gr8 Thank you!!!!!!!!

    ReplyDelete
  10. how to combine text and image in marquee??

    ReplyDelete
  11. www.anticosalento.com
    how to use xmldatascource along with repeater control

    ReplyDelete
  12. i will also use this type of code but marquee will not display text or image continuous rotation means the image or text will once dispplay then after some going space and after some time it will disply so hoe it will disply continuous

    ReplyDelete
  13. database retrieve data to use the marquue tag

    ReplyDelete