在计时器

时间:2016-01-30 06:15:56

标签: c# html asp.net timer

我有三个div 每个显示在 3秒间隔的间隙内。在Page_load上显示第一个div数据,然后在 3秒之后显示另一个div数据。

所以,

  

现在我想要的是,现在经过3秒钟后,我想显示第三个div数据。

以下是我的简单HTML TIMER

<asp:UpdatePanel ID="up" runat="server">
    <ContentTemplate>
        <table style="width: 100%; text-align: center" border="1" runat="server" id="tbl1Details">
            <colgroup>
                <col width="5%" />
                <col width="45%" />
            </colgroup>
            <tr>
                <td colspan="3">
                    <asp:Label ID="lblpltfrm_Number" runat="server"></asp:Label>
                </td>
            </tr>
            <tr>
                <td>
                    SR.
                </td>
                <td>
                    Stop
                </td>
                <td>
                    Time
                </td>
            </tr>
            <tr>
                <td id="tTime" runat="server">
                    <div id="list" runat="server">
                    </div>
                </td>
                <td>
                    <table style="width: 100%">
                        <colgroup>
                            <col width="50%" />
                            <col width="50%" />
                        </colgroup>
                        <tr>
                            <td style="text-align: left">
                                <div id="dv_FromStop" runat="server">
                                </div>
                            </td>
                            <td style="text-align: left">
                                <div id="Dv_ToStop" runat="server">
                                </div>
                            </td>
                        </tr>
                    </table>
                </td>
                <td>
                    <div id="dv_Time" runat="server">
                    </div>
                </td>
            </tr>
        </table>
        <!--2nd Screen-->
        <table style="width: 100%; text-align: center" border="1" runat="server" id="tbl2Details"
            visible="false">
            <colgroup>
                <col width="5%" />
                <col width="45%" />
            </colgroup>
            <tr>
                <td colspan="3">
                    <asp:Label ID="lbl2ndpltfrm" runat="server"></asp:Label>
                </td>
            </tr>
            <tr>
                <td>
                    SR.
                </td>
                <td>
                    Stop
                </td>
                <td>
                    Time
                </td>
            </tr>
            <tr>
                <td>
                    <div id="dv2SRNo" runat="server">
                    </div>
                </td>
                <td>
                    <table style="width: 100%">
                        <colgroup>
                            <col width="50%" />
                            <col width="50%" />
                        </colgroup>
                        <tr>
                            <td style="text-align: left">
                                <div id="dv2From_Stop" runat="server">
                                </div>
                            </td>
                            <td style="text-align: left">
                                <div id="dv2ToStop" runat="server">
                                </div>
                            </td>
                        </tr>
                    </table>
                </td>
                <td>
                    <div id="dv2Time" runat="server">
                    </div>
                </td>
            </tr>
        </table>
        <table id="tbl3Details" style="width: 100%; text-align: center" border="1" runat="server">
            <colgroup>
                <col width="5%" />
                <col width="45%" />
            </colgroup>
            <tr>
                <td colspan="3">
                    <asp:Label ID="lbl3rdpltfrm" runat="server"></asp:Label>
                </td>
            </tr>
            <tr>
                <td>
                    SR.
                </td>
                <td>
                    Stop
                </td>
                <td>
                    Time
                </td>
            </tr>
            <tr>
                <td>
                    <div id="dv3SRNo" runat="server">
                    </div>
                </td>
                <td>
                    <table style="width: 100%">
                        <colgroup>
                            <col width="50%" />
                            <col width="50%" />
                        </colgroup>
                        <tr>
                            <td style="text-align: left">
                                <div id="dv3From_Stop" runat="server">
                                </div>
                            </td>
                            <td style="text-align: left">
                                <div id="dv3To_Stop" runat="server">
                                </div>
                            </td>
                        </tr>
                    </table>
                </td>
                <td>
                    <div id="dv3Time" runat="server">
                    </div>
                </td>
            </tr>
        </table>
        <asp:Timer ID="Timer1" runat="server" OnTick="GetTime2" Interval="3000" />
    </ContentTemplate>
</asp:UpdatePanel>

现在处理的主要问题是这背后的代码: -

看看

protected void Page_Load(object sender, EventArgs e)
{

    if (!this.IsPostBack)
    {
        GetPlt1Details();
        Session["NextPlatForm"] = 1;
    }
}

protected void GetPlt1Details()
{
    lblpltfrm_Number.Text = "PlatForm 1";
    list.InnerHtml = "";
    dv_FromStop.InnerHtml = "";
    Dv_ToStop.InnerHtml = "";
    dv_Time.InnerHtml = "";
    int svalue = Convert.ToInt32(Session["ReloadValue"]);
    DataTable obj_Dt = new DataTable();
    OracleConnection obj_Connection = new OracleConnection(System.Configuration.ConfigurationManager.ConnectionStrings["OracleConn"].ToString());

    string Query = "Select x.SR_NO,x.FROM_STOP,x.TO_STOP,x.ORIGIN_STOP_TIME from XXACL_PN_BUS_TIMETABLE x WHERE SCREEN_NUMBER=1";
    using (OracleCommand obj_Command = new OracleCommand(Query))
    {
        OracleDataAdapter obj_Adapter = new OracleDataAdapter(obj_Command);
        obj_Command.Connection = obj_Connection;
        obj_Adapter.SelectCommand = obj_Command;
        obj_Adapter.Fill(obj_Dt);
        int Count = obj_Dt.Rows.Count;
        for (int i = 0; i < obj_Dt.Rows.Count; i++)
        {
            if (i < 2)
            {
                list.InnerHtml = list.InnerHtml + "<br />" +
                     obj_Dt.Rows[i]["SR_NO"];
                dv_FromStop.InnerHtml = dv_FromStop.InnerHtml + "<br />" +
                    obj_Dt.Rows[i]["FROM_STOP"];
                Dv_ToStop.InnerHtml = Dv_ToStop.InnerHtml + "<br />" +
                    obj_Dt.Rows[i]["TO_STOP"];
                dv_Time.InnerHtml = dv_Time.InnerHtml + "<br />" +
                    obj_Dt.Rows[i]["ORIGIN_STOP_TIME"];
            }
            else
            {
                Session["NextPlatForm"] = 1;
                Session["A"] = "PlatForm 1";
                dv2SRNo.InnerHtml = dv2SRNo.InnerHtml + "<br />" +
                 obj_Dt.Rows[i]["SR_NO"];
                dv2From_Stop.InnerHtml = dv2From_Stop.InnerHtml + "<br />" +
                    obj_Dt.Rows[i]["FROM_STOP"];
                dv2ToStop.InnerHtml = dv2ToStop.InnerHtml + "<br />" +
                    obj_Dt.Rows[i]["TO_STOP"];
                dv2Time.InnerHtml = dv2Time.InnerHtml + "<br />" +
                    obj_Dt.Rows[i]["ORIGIN_STOP_TIME"];
            }
        }
    }
}

protected void GetTime2(object sender, EventArgs e)
{
    int pvalue = Convert.ToInt32(Session["NextPlatForm"]);
    if (pvalue != 2)
    {
        tbl1Details.Visible = false;
        tbl2Details.Visible = true;
        string a = string.Empty;
        a = Convert.ToString(Session["A"]);
        if (string.IsNullOrEmpty(a) == false)
        {
            lbl2ndpltfrm.Text = a;
        }
    }
    else
    {
        tbl1Details.Visible = true;
        tbl2Details.Visible = false;
        lblpltfrm_Number.Text = "PlatForm 2";
        list.InnerHtml = "";
        dv_FromStop.InnerHtml = "";
        Dv_ToStop.InnerHtml = "";
        dv_Time.InnerHtml = "";
        OracleConnection obj_Connection = new OracleConnection(System.Configuration.ConfigurationManager.ConnectionStrings["OracleConn"].ToString());
        string Query2 = "Select x.SR_NO,x.FROM_STOP,x.TO_STOP,x.ORIGIN_STOP_TIME from XXACL_PN_BUS_TIMETABLE x WHERE SCREEN_NUMBER=2";
        DataTable obj_Dt = new DataTable();
        using (OracleCommand obj_Command = new OracleCommand(Query2))
        {
            OracleDataAdapter obj_Adapter = new OracleDataAdapter(obj_Command);
            obj_Command.Connection = obj_Connection;
            obj_Adapter.SelectCommand = obj_Command;
            obj_Adapter.Fill(obj_Dt);
            int Count = obj_Dt.Rows.Count;
            for (int i = 0; i < obj_Dt.Rows.Count; i++)
            {
                list.InnerHtml = list.InnerHtml + "<br />" +
                      obj_Dt.Rows[i]["SR_NO"];
                dv_FromStop.InnerHtml = dv_FromStop.InnerHtml + "<br />" +
                    obj_Dt.Rows[i]["FROM_STOP"];
                Dv_ToStop.InnerHtml = Dv_ToStop.InnerHtml + "<br />" +
                    obj_Dt.Rows[i]["TO_STOP"];
                dv_Time.InnerHtml = dv_Time.InnerHtml + "<br />" +
                    obj_Dt.Rows[i]["ORIGIN_STOP_TIME"];
            }
        }
    }
    Session["NextPlatForm"] = 2;
}

现在,关于这一点,我如何显示第三个div数据

0 个答案:

没有答案