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