• 滚动的gridview


    代码
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title></title>
    <style type="text/css">
    .blk_02
    {
    margin-top
    : 0px;
    text-align
    : center;
    height
    : 263px;
    width
    : 1810px;
    }
    .blk_02 .table_title table
    {
    border-left
    : 0px solid #b3d3ec;
    border-top
    : 0px solid #b3d3ec;
    background
    : #e0f0fd;
    color
    : #5198cc;
    width
    : 1927px;
    }
    .blk_02 .table_title table th
    {
    border-right
    : 0px solid #b3d3ec;
    border-bottom
    : 0px solid #b3d3ec;
    height
    : 20px;
    font-weight
    : normal;
    text-align
    : center;
    }
    .blk_02 .table_data
    {
    height
    : 129px;
    overflow
    : auto;

    width
    : 834px;
    }
    .blk_02 .table_data table
    {
    border-left
    : 0px solid #b3d3ec;
    margin-left
    : 0px;
    text-align
    : left;
    }
    .blk_02 .table_data table td
    {
    border-right
    : 0px solid #b3d3ec;
    border-bottom
    : 0px solid #b3d3ec;
    height
    : 24px;
    font-weight
    : normal;
    text-align
    : center;
    }
    .style1
    {
    width
    : 772px;
    }
    .style2
    {
    height
    : 21px;
    }
    #demo1
    {
    width
    : 834px;
    text-align
    : left;
    }
    .style3
    {
    width
    : 274px;
    }
    .style4
    {
    width
    : 271px;
    }
    .style5
    {
    width
    : 278px;
    }
    .style6
    {
    width
    : 282px;
    }
    .style7
    {
    width
    : 270px;
    }
    </style>
    </head>
    <body>
    <form id="form1" runat="server">
    <div class="blk_02" id="chg">
    <div class="table_title" style=" 1746px; text-align: center">

    <table style="96%;">
    <tr>
    <td colspan="3" class="style2">
    沪 指
    </td>
    <td colspan="3" class="style2">
    深 指
    </td>
    </tr>
    <tr>
    <td colspan="3">
    上证指数:
    <%=szzs %></td>
    <td colspan="3">
    深圳成指:
    <%=szcz %></td>
    </tr>
    <tr>
    <td class="style4">
    名 称
    </td>
    <td class="style5">
    开盘价
    </td>
    <td class="style3">
    收盘价
    </td>
    <td class="style6">
    名 称
    </td>
    <td class="style7">
    开盘价
    </td>
    <td>
    收盘价
    </td>
    </tr>
    </table>
    </div>
    <table>
    <tr>
    <td class="style1">
    <div class="table_data" id="demo" style="overflow:hidden;scroll:no">
    <div id="demo1">
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
    Width
    ="837px" ShowHeader="False" onrowdatabound="GridView1_RowDataBound">
    <Columns>
    <asp:BoundField DataField="s2" HeaderText="名称" >
    <ItemStyle Width="33%" />
    </asp:BoundField>
    <asp:BoundField DataField="s4" HeaderText="开盘价" >
    <ItemStyle Width="33%" />
    </asp:BoundField>
    <asp:BoundField DataField="s8" HeaderText="收盘价" >
    <ItemStyle Width="33%" />
    </asp:BoundField>
    </Columns>
    </asp:GridView>
    </div>
    </div>
    </td>

    <td>
    <div class="table_data" id="demo3"
    style
    ="overflow:hidden;scroll:no; text-align: left;">
    <div id="demo2" style="top: 0px; left: 0px; 835px; text-align: left;">
    <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"
    ShowHeader
    ="False" Width="833px" onrowdatabound="GridView2_RowDataBound">
    <Columns>
    <asp:BoundField DataField="HQZQJC" HeaderText="名 称" >
    <ItemStyle Width="33%" />
    </asp:BoundField>
    <asp:BoundField DataField="HQJRKP" HeaderText="开盘价" >
    <ItemStyle Width="33%" />
    </asp:BoundField>
    <asp:BoundField DataField="HQZJCJ" HeaderText="收盘价">
    <ItemStyle Width="33%" />
    </asp:BoundField>
    </Columns>
    </asp:GridView>
    </div>
    </div>
    </td>
    </tr>
    </table>
    </div>

    <script type="text/javascript">
    var speed = 30
    function Marquee() {
    if (document.getElementById("demo").scrollTop >= document.getElementById("demo1").offsetHeight - document.getElementById("demo").offsetHeight)
    {
    document.getElementById(
    "demo").scrollTop = 0;
    }
    else
    {
    document.getElementById(
    "demo").scrollTop++
    }
    if (document.getElementById("demo3").scrollTop >= document.getElementById("demo2").offsetHeight - document.getElementById("demo3").offsetHeight) {
    document.getElementById(
    "demo3").scrollTop = 0;
    }
    else {
    document.getElementById(
    "demo3").scrollTop++
    }
    }
    var MyMar = setInterval(Marquee, speed)
    document.getElementById(
    "demo").onmouseover = function() { clearInterval(MyMar) }
    document.getElementById(
    "demo").onmouseout = function() { MyMar = setInterval(Marquee, speed) }
    </script>
    </form>
    </body>
    </html>



    代码
    CS代码

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;
    using System.Data.OleDb;
    using System.Data.Odbc;



    namespace WebApplication1
    {
    public partial class _Default : System.Web.UI.Page
    {
    public static System.Data.DataTable dt;
    public static string szzs, szcz;

    protected void Page_Load(object sender, EventArgs e)
    {
    if (!IsPostBack)
    {
    OdbcConnection odbccon
    = new OdbcConnection();
    odbccon.ConnectionString
    ="dsn=dbflink1";
    odbccon.Open();
    string str = string.Format("select S2,S4,S8 from show2003");
    OdbcDataAdapter odb
    = new OdbcDataAdapter(str, odbccon);
    System.Data.DataSet ds
    = new DataSet();
    odb.Fill(ds);
    szzs
    =ds.Tables[0].Rows[1].ItemArray[2].ToString();
    this.GridView1.DataSource = ds;
    this.GridView1.DataBind();

    string str1 = string.Format("select HQZQJC,HQJRKP,HQZJCJ from SJSHQ");
    //string str1 = string.Format("select S2,S8 from show2003");
    OdbcDataAdapter odb1 = new OdbcDataAdapter(str1, odbccon);
    System.Data.DataSet ds1
    = new DataSet();
    odb1.Fill(ds1);
    this.GridView2.DataSource = ds1;
    this.GridView2.DataBind();


    string str2 = string.Format("select ZSZJZS from SJSZS");
    //string str1 = string.Format("select S2,S8 from show2003");
    OdbcDataAdapter odb2 = new OdbcDataAdapter(str2, odbccon);
    System.Data.DataSet ds2
    = new DataSet();
    odb1.Fill(ds2);
    szcz
    = ds2.Tables[0].Rows[2].ItemArray[0].ToString();

    odbccon.Close();
    }
    }

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
    if (Convert.ToSingle(e.Row.Cells[1].Text) < Convert.ToSingle(e.Row.Cells[2].Text))
    {
    e.Row.ForeColor
    = System.Drawing.Color.Red;
    }
    else
    {
    e.Row.ForeColor
    = System.Drawing.Color.Green;

    }
    if (Convert.ToSingle(e.Row.Cells[1].Text) == Convert.ToSingle(e.Row.Cells[2].Text))
    {
    e.Row.ForeColor
    = System.Drawing.Color.Yellow;
    }
    }
    }

    protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
    {
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
    if (Convert.ToSingle(e.Row.Cells[1].Text.Length) < Convert.ToSingle(e.Row.Cells[2].Text.Length))
    {
    e.Row.ForeColor
    = System.Drawing.Color.Red;
    }
    else
    {
    e.Row.ForeColor
    = System.Drawing.Color.Green;

    }
    if (Convert.ToSingle(e.Row.Cells[1].Text.Length) == Convert.ToSingle(e.Row.Cells[2].Text.Length))
    {
    e.Row.ForeColor
    = System.Drawing.Color.Yellow;
    }

    }
    }
    }

    }
  • 相关阅读:
    ios 一个正则表达式测试(只可输入中文、字母和数字)
    IOS7 8中tableview分割线缺少15像素
    Java中使用OpenSSL生成的RSA公私钥进行数据加解密
    java与IOS之间的RSA加解密
    ios下使用rsa算法与php进行加解密通讯
    C# 32位md5
    [原]命令模式在MVC框架中的应用
    [原]【推荐】程序员必读的三十本经典巨作
    [原]容器学习(二):动手模拟AOP
    [原]容器学习(一):动手模拟spring的IoC
  • 原文地址:https://www.cnblogs.com/zgz_dpl/p/1876685.html
Copyright © 2020-2023  润新知