2013-04-19 1 views
0

У меня есть ретранслятор, который отображает «Новости» на домашней странице, которая дублируется из базы данных. Я хочу отображать только 2 записи одновременно и автоматически прокручивать следующие два элемента после определенных миллисекунд с эффектом прокрутки или fadein-fadeout.Как показать x-элементы в Repeater и прокрутить или fadein-fadeout следующие элементы, используя asp.net?

В 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>&nbsp;</td> 
        </tr> 
        <tr width="100px"> 
         <td> 
          <asp:Label ID="lblNewsDescription" runat="server" /></td> 
         <td>&nbsp;</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(); 

       } 
      } 

Помощь Оценил! Спасибо!

+0

, так как вы с тегами JQuery Я предполагаю, что вы бы принять решение JQuery тоже: http://jquerytools.org/demos/scrollable/ – Yeronimo

+0

привет @Yeronimo, я хочу, чтобы просмотреть автоматически через некоторое время после каждых 2 секунд он должен отображать следующие две записи в ретрансляторе –

+0

прокручиваемый, о котором я говорил, может сделать это: http://jquerytools.org/documentation/scrollable/autoscroll.html – Yeronimo

ответ

0

Попробуйте использовать какой-то JQuery слайдер

Смежные вопросы