First, I used marquee with repeater and it is working fine, but it shows all data at the same time.
My code look like this :
<marquee id="ml" style="text-align: center" width="400px" height="170"
scrolldelay="5" scrollamount="5">
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<br />
<asp:Label ID="Label1" runat="server" Text='<%# Eval("notification") %>'></asp:Label><br />
</ItemTemplate>
</asp:Repeater>
</marquee>
Here is my code behind page below:
private void getnotification()
{
DataTable notifydt = new DataTable();
DateTime currentdt = DateTime.Now;
string date1 = currentdt.ToString("yyyy-MM-dd");
string qry = "";
qry = "select notification from adminnotification where visibility=1 and FromDate >='" + date1 + "'";
SqlDataAdapter sda = new SqlDataAdapter(qry, con);
StringBuilder sb = new StringBuilder();
con.Open();
sda.Fill(notifydt);
int count = notifydt.Rows.Count;
DataView dv = new DataView(notifydt);
if (count > 0)
{
foreach (DataRow DR in notifydt.Rows)
{
dv.RowFilter = "notification='" + DR["Notification"].ToString()+ "'";
}
Repeater1.DataSource = dv;
Repeater1.DataBind();
}
}
I want to show data one by one, how can I do that ?
Thank you in advance,
There are few things you can check
The Repeater control has no horizontal or vertical "direction". You either need to control it via css:
<ItemTemplate>
<div style="float:left">
<asp:Label ID="Label1" runat="server" Text='<%# Eval("notification") %>' />
</div>
</ItemTemplate>
or use other controls like DataList, where you could set direction
<asp:DataList RepeatDirection="Horizontal" ... >
The following filter makes no sense and needs to be deleted
foreach (DataRow DR in notifydt.Rows)
{
dv.RowFilter = "notification='" + DR["Notification"].ToString()+ "'";
}
The filter by date could be set directly in sql. For example, if you use SQL Server then you could use the getdate() function
where visibility=1 and FromDate >= getdate()
To get only date you could use Convert(date, getdate()), see documentation for your database for more details.