SIGN UP MEMBER LOGIN:    
Blog

Marquee with repeater control with data fetched from SQLDatabase

Posted by Parul Agrawal Blogs | ADO.NET in C# Nov 23, 2011
In this blog you will learn how to implement marquee with repeater control with data fetched from SQLDatabase.

Code to Implement Marquee with repeater control with data fetched from SQLDatabase

In Page Source

<table>
    <tr>
        <td valign="top">
            <marquee id="ml" style="text-align: center" direction="up" width="200px" height="500px"
                scrolldelay="20" scrollamount="1"><asp:Repeater id="Repeater1" runat="server">
<ItemTemplate>
<
br />
<asp:Image ID="Image1" Width="200px" Height="200px" runat="server" ImageUrl='<%# Eval("Photo") %>'></asp:Image> <br />
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("Photo") %>'>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("PhotoName") %>'></asp:Label></asp:HyperLink><br />
</ItemTemplate>
</
asp:Repeater></marquee>
        </td>
    </tr>
</table>

In Code Window

Master_Class objMaster_Class = new Master_Class();
protected void Page_Load(object sender, EventArgs e)
{
     Repeater1.DataSource = GetEvents();
     Repeater1.DataBind();
}
public DataSet GetEvents()
{
     string sql = "select * from Album";
     SqlConnection conn = new SqlConnection(connString); {
        conn.Open();
        SqlDataAdapter da = new SqlDataAdapter(sql, conn);
        DataSet ds = new DataSet();
        da.Fill(ds);
               
        DataTable dt = new DataTable();
        dt.Columns.Add(new DataColumn("PhotoID", typeof(Int32)));
        dt.Columns.Add(new DataColumn("Photo", typeof(string)));
//url path of photo.
        dt.Columns.Add(new DataColumn("PhotoName", typeof(string)));
        DataRow dr;
        int i = 1;
        int len = Convert.ToInt16(ds.Tables[0].Rows.Count);
        if (ds.Tables[0].Rows.Count > 0)
        {
             for (i = 0; i < len; i++)
             {
                  dr = dt.NewRow();
                  dr["PhotoID"] = Convert.ToInt16(ds.Tables[0].Rows[i]["PhotoID"]);
                  dr["Photo"] = ds.Tables[0].Rows[i]["Photo"].ToString();
                  dr["PhotoName"] = ds.Tables[0].Rows[i]["PhotoName"].ToString();
                  dt.Rows.Add(dr);
             }
        }
        return ds;
}

share this blog :
post comment
 

I am trying to use this code in Visual Studio 2010 but the element "marquee" is not supported.I want to create a control that displays some scrolling texts. These texts would be fetched from SQL Server database one after the other and then displayed one at a time. I would be grateful if any one can help.

Posted by Olugbenga Shittu Nov 25, 2011