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

An HTML marquee is a scrolling piece of text that, depending on the settings, appears horizontally across or vertically down your webpage. This is accomplished through the use of the HTML marquees> tag.

Note − The tag deprecated in HTML5. Do not use this element, instead you can use JavaScript and CSS to create such effects.

<%@ 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;
    }
}

Please do not post any spam link in the comment box😊

إرسال تعليق (0)
أحدث أقدم