在ASP.NET中水平滚动数据列表 [英] Horizontal scrolling of datalist in asp.net

查看:46
本文介绍了在ASP.NET中水平滚动数据列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个测试项目
aspx文件如下

I have one test project
the aspx file is as follows

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="testDataTable._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .DD_wrap_2
        {
            width: 756px;
            float: left;
            height: 109px;
            background-image: url('../deals_bg_2.jpg');
            background-repeat: no-repeat;
            background-color: White;
            margin-left: 0px;
            margin-right: 0px;
            margin-top: 0px;
            margin-bottom: 0px;
            padding-bottom: 0px;
        }
        .outerDiv
        {
            width: auto;
            height: auto;
            float: left;
            border-style: solid;
            border-width: thin;
        }
        .valueDiv
        {
            width: 50px;
            height: auto;
            float: left;
        }
        .questionDiv
        {
            width: 200px;
            height: auto;
            float: left;
        }
        .modeDiv
        {
            width: 100px;
            height: auto;
            float: left;
        }
        .d_deals_2
        {
            width: 135px;
            height: 108px;
            float: left;
            font-family: Arial, Helvetica, sans-serif;
            font-size: 15px;
            color: #000000;
            margin: 0px 0px 0px 15px;
            padding: 48px 0px 0px 0px;
        }
        .deals_arrow_L
        {
            width: 14px;
            height: 108px;
            float: left;
        }
        .deals_arrow_R
        {
            width: 14px;
            height: 108px;
            float: left;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div class="DD_wrap_2">
        <div class="d_deals_2">
            Deals of the week<br />
        </div>
        <div class="deals_arrow_L">
            <img src="../do_arrow_l.jpg" width="14" height="108" />
        </div>
        <div style="float:left;overflow:hidden;">
             <asp:DataList ID="PollDatalist" runat="server" RepeatDirection="Horizontal">
            <ItemTemplate>
                <div style="float: left">
                    <%# Eval("PollID")%></div>
                <div style="float: left; width: 70px; height: 109px;">
                    <%# Eval("Question")%></div>
            </ItemTemplate>
            <FooterTemplate>
            </FooterTemplate>
        </asp:DataList>

         </div>

        <div class="deals_arrow_R">
            <img src="../do_arrow_r.jpg" width="14" height="108" /></div>
    </div>
    </form>
</body>
</html>


我后面的代码如下:


and my code behind is as follows:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
namespace testDataTable
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            bindData();
        }
        public void bindData()
        {
            DataSet ds = new DataSet();
            
            string conString = ConfigurationManager.AppSettings["testConString"];
            SqlConnection conObject = new SqlConnection();
            conObject.ConnectionString = conString;
            try
            {
                conObject.Open();
                SqlDataAdapter ad = new SqlDataAdapter(helperClass(), conObject);
                ad.Fill(ds);
                
            }
            catch (SqlException E)
            { 
                           
            }
            finally
            {
                conObject.Close();    
                
            }
            DataTable dt = createDataTable();
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                DataRow dr = dt.NewRow();
                if (ds.Tables[0].Rows[i]["PollID"] != System.DBNull.Value)
                {
                    dr["PollID"] = ds.Tables[0].Rows[i]["PollID"];
                }
                if (ds.Tables[0].Rows[i]["Question"] != System.DBNull.Value)
                {
                    dr["Question"] = ds.Tables[0].Rows[i]["Question"];
                }
                if (ds.Tables[0].Rows[i]["BlockMode"] != System.DBNull.Value)
                {
                    dr["BlockMode"] = ds.Tables[0].Rows[i]["BlockMode"];
                }
                if (ds.Tables[0].Rows[i]["Active"] != System.DBNull.Value)
                {
                    dr["Active"] = ds.Tables[0].Rows[i]["Active"];
                }
                dt.Rows.Add(dr);
            }

            PollDatalist.DataSource = dt;
            PollDatalist.DataBind();
            
        }
        public DataTable createDataTable()
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("PollID", typeof(System.Int32));
            dt.Columns.Add("Question", typeof(System.String));
            dt.Columns.Add("BlockMode", typeof(System.String));
            dt.Columns.Add("Active", typeof(SqlDbType));
           
            return dt;
        }
        public string helperClass()
        {
            return  "usp_getPollquestions";
        
        }
    }
}


我想将数据悬停在左或右image.i上,以便从数据列表中移动结果.我知道我可以使用jquery或javascript做到这一点,因为我不是javascript程序员,所以有人可以帮助我完成此任务吗?
谢谢
[edit]添加了代码块-OriginalGriff [/edit]


i Want to move result from datalist as i hover my mouse on left or right image.i Know that i can do this with jquery or javascript can anyone help me to acquire this task as i am not javascript programmer
thanks
[edit]Code block added - OriginalGriff[/edit]

推荐答案

^ ]可能会对您有所帮助.
This[^] may help you.


这篇关于在ASP.NET中水平滚动数据列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆