データベースから表示されるホームページに「ニュース」を表示するリピーターがあります。一度に2レコードだけを表示し、スクロールまたはフェードインフェードアウト効果を使用して、特定のミリ秒後に次の2つのアイテムを自動的にスクロールしたい。
aspx ページ:
<asp:Repeater ID="RepDetails" runat="server" OnItemDataBound="RepDetails_ItemDataBound">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<div id="MainContent" style="border: 1px;">
<table>
<tr>
<td rowspan="2" class="auto-style2">
<img src="Images/lasts1.png" />
</td>
<td>
<asp:Label ID="lblNewsTitle" runat="server" Font-Bold="True" /></td>
<td> </td>
</tr>
<tr width="100px">
<td>
<asp:Label ID="lblNewsDescription" runat="server" /></td>
<td> </td>
</tr>
</table>
</div>
<hr />
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
.cs ページ:
protected void RepDetails_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
DataRowView dr = e.Item.DataItem as DataRowView;
string Id = Convert.ToString(dr["NewsID"]);
//HtmlGenericControl teammemberapp = e.Item.FindControl("teammemberapp") as HtmlGenericControl;
//Link to TeamMemberDetails Page
//teammemberapp.Attributes.Add("onclick", "window.location.href='NewsDetails.aspx?Id=" + Id + "'");
string newsTitle = Convert.ToString(dr["NewsTitle"]);
Label lblNewsDescription = e.Item.FindControl("lblNewsDescription") as Label;
Label lblNewsTitle = e.Item.FindControl("lblNewsTitle") as Label;
//set First Name Label
lblNewsTitle.Text = newsTitle;
string newsDescription = Convert.ToString(dr["NewsDescription"]);
if (newsDescription.Length > 50)
{
lblNewsDescription.Text = newsDescription.Substring(0, 50) + "..";
}
else
{
lblNewsDescription.Text = newsDescription;
}
}
}
public void GetRecord()
{
string connectionString = ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString.ToString();
DataTable datatable = new DataTable();
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = connection;
connection.Open();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "usp_NewsSelectYES";
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(datatable);
connection.Close();
}
//Bind Table to Repeater
RepDetails.DataSource = datatable;
RepDetails.DataBind();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//Get all news with yes
GetRecord();
}
}
助けて感謝!ありがとう!