同一个aspx(c#)网页,不同地方跳转竟然导致该网页不能显示分页功能

同一个aspx(c#)网页,不同地方跳转竟然导致该网页不能显示分页功能。
其实之前是一切正常的,但是自从我在gridview新增一个button列以后就出问题了。
除了不能正常显示分页外是以我业余的水平不能解决!

图片说明

using System;
using System.Web.UI.WebControls;
using System.Data;
using Core;
using System.Text.RegularExpressions;

namespace tbportal
{
    public partial class staff_briefing_history : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["staff"] == null && Session["staffno"] == null)
            {
                Response.Redirect("login.aspx");
            }
            else
            {
                if (!IsPostBack)
                {
                    if (Session["staff"] == null)
                    {
                        Label_staffno.Text = Session["staffno"].ToString();
                    }
                    else
                    {
                        Label_staffno.Text = Session["staff"].ToString();
                    }
                    if (Session["namec"] == null)
                    {
                        Label_name.Text = Session["name"].ToString();
                    }
                    else
                    {
                        Label_name.Text = Session["namec"].ToString();
                    }
                    if (Session["device"] == null)
                    {
                        Label_sit.Text = "OFFICE";
                    }
                    else
                    {
                        Label_sit.Text = Session["device"].ToString();
                    }
                    if (Session["authority"].ToString() != "OP")
                    {
                        Button_backtoadmin.Visible = true;

                    }
                    Session["gridview_type"] = "0";
                    loadingData_history();
                }


            }

        }
        private void loadingData_history()
        {
            dbconn a = new dbconn();
            DataSet ds = new DataSet();
            ds = a.selectdatabase("SELECT Message_ID as 'ID',Message_body as '內容',sender_ID as '發布人',create_time as '創建時間',modify_times as '修改次數',Last_modify_user as '最後修改人' from staff_briefing order by create_time desc", "ps");
            GridView1.DataSource = ds;
            //GridView1.HeaderStyle.Width = "100px";
            GridView1.CellSpacing = 4;
            GridView1.DataBind();
            check_modify();//修改顯示紅色字體
            next_row_gridview1();//加入換行替代

        }
        protected void next_row_gridview1() //將文本內容的下一行和空格顯示實際效果,日期格式更新
        {

            int Total_Rows = GridView1.Rows.Count;
            Regex rex = new Regex("<br/>");

            for (int d_row = 0; d_row < Total_Rows; d_row++)
            {
                string a = GridView1.Rows[d_row].Cells[3].Text;
                string b = rex.Replace(a, "<br/>");
                GridView1.Rows[d_row].Cells[3].Text = b;

            }

            for (int d_row = 0; d_row < Total_Rows; d_row++) //日期格式變更
            {

                DateTime dt = Convert.ToDateTime(GridView1.Rows[d_row].Cells[5].Text.ToString());
                GridView1.Rows[d_row].Cells[5].Text = dt.ToString("yyyy-MM-dd HH:mm:s");

            }


        }
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (Session["authority"].ToString()== "OP") //如果是OP權限則不顯示修改按鈕
            {

                e.Row.Cells[0].Attributes.Add("style", "display:none");
            }

            int i;
            for (i = 0; i <= GridView1.Rows.Count; i++)
            {
                //首先判断是否是数据行
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    //当鼠标停留时更改背景色
                    e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#00A9FF'");
                    //当鼠标移开时还原背景色
                    e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
                    //单击行的任意列会自动选中此行
                    // e.Row.Attributes.Add("onclick", "__doPostBack('GridView1','Select$" + e.Row.RowIndex + "')");
                }
            }


        }
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                if (e.CommandName == "modify" && Session["authority"].ToString() != "OP")
                {   

                    Session["Message_ID"] = GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[2].Text.ToString();
                    Session["Message_body"] = GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[3].Text.ToString();
                    dbconn a = new tbportal.dbconn();
                    DataSet ds = new DataSet();
                    ds = a.selectdatabase("select msg_type from staff_briefing where staff_briefing.Message_ID='"+ GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[2].Text.ToString() + "'", "ps");
                    Session["msg_type"] = ds.Tables[0].Rows[0][0].ToString();

                    this.Response.Write("<script language=javascript>window.open('staff_briefing_modify.aspx','newwindow','width=700,height=400,top=500, left=500,')</script>");
                    // Page.ClientScript.RegisterStartupScript(this.GetType(),"名称","< script > document.location = document.location; </ script > ");
                    //this.Response.Write("<script language=javascript>window.open(’staff_briefing_modify.aspx’,’newwindow’,’width=200,height=200’)</script>");
                }
                else if (e.CommandName == "add_favorite")
                {

                    int index = Convert.ToInt32(e.CommandArgument);
                    //GridViewRow row = GridView1.Rows[index];
                    string row_id = GridView1.Rows[index].Cells[2].Text.ToString();
                    //MessageBox.write(GridView1.Rows[index].Cells[1].Text.ToString(),"briefing.aspx");
                    dbconn aa = new dbconn();
                    int res = aa.UpDataBase("update staff_briefing_readstatus set favorite=1 where Message_ID='" + row_id + "' AND  staff_ID='" + Label_staffno.Text.ToString() + "'");

                    if (res > 0)
                    {

                        GridView1.Rows[index].Cells[1].BackColor = System.Drawing.Color.Green;
                    }

                }


            }
            catch (Exception err)
            {
                MessageBox.write(err.Message, "staff_briefing_history.aspx");
            }
            finally
            {

            }
        }
        protected void check_modify()
        {
            int Total_Rows = GridView1.Rows.Count;
            for (int a_Rows = 0; a_Rows < Total_Rows; a_Rows++)
            {
                if (int.Parse(GridView1.Rows[a_Rows].Cells[6].Text.ToString()) > 0)
                {
                    GridView1.Rows[a_Rows].ForeColor = System.Drawing.Color.Red;
                }
            }



        }
        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView1.PageIndex = e.NewPageIndex;

            switch (Session["gridview_type"].ToString())
            {
                case "0":
                    loadingData_history();
                    break;
                case "1":
                    Button_Info_games_Click(null, null);
                    break;
                case "2":
                    Button_Others_Click(null, null);
                    break;
                case "3":
                    Button_Ref_info_Click(null, null);
                    break;
                case "4":
                    break;

            }


        }

        protected void Button_search_Click(object sender, EventArgs e)
        {
            try
            {
                dbconn a = new dbconn();
                DataSet ds = new DataSet();
                GridView1.DataSource = null;

                string db_comm = "SELECT Message_ID as 'ID',Message_body as '內容',sender_ID as '發布人',create_time as '創建時間',modify_times as '修改次數',Last_modify_user as '最後修改人' from staff_briefing where staff_briefing.Message_body like '%" + TextBox_search.Text.ToString() + "%' order by create_time desc";

                ds = a.selectdatabase(db_comm, "ps");
                GridView1.DataSource = ds;
                //GridView1.HeaderStyle.Width = "100px";
                GridView1.DataBind();
                next_row_gridview1();
                check_modify();

                Session["gridview_type"] = "4";
                //Session["body"] = TextBox_search.Text.ToString();
                //this.Response.Write("<script language=javascript>window.open('briefing_search.aspx','newwindow','width=900,height=500,top=500, left=500,')</script>");
            }
            catch (Exception err)
            {
                MessageBox.write(err.ToString(), "staff_briefing_history.aspx");
            }
        }

        protected void Button_logout_Click(object sender, EventArgs e)
        {
            Session.Clear();
            MessageBox.write("你已經成功登出!!","staff_briefing_history.aspx");
        }

        protected void Button_backtoadmin_Click(object sender, EventArgs e)
        {
            try
            {
                Response.Redirect("briefing.aspx");
            }
            catch (Exception err)
            {
                MessageBox.write(err.ToString(),"staff_briefing_history.aspx");
            }
        }

        protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Header)
            {
                e.Row.Cells[2].Visible = false;
            }
        }

        protected void Button_Info_games_Click(object sender, EventArgs e)
        {
            dbconn a = new dbconn();
            DataSet ds = new DataSet();
            ds = a.selectdatabase("SELECT Message_ID as 'ID',Message_body as '內容',sender_ID as '發布人',create_time as '創建時間',modify_times as '修改次數',Last_modify_user as '最後修改人' from staff_briefing where msg_type='Info_games' order by create_time desc", "ps");
            GridView1.DataSource = ds;
            //GridView1.HeaderStyle.Width = "100px";
            GridView1.CellSpacing = 4;
            GridView1.DataBind();
            check_modify();
            next_row_gridview1();

            Session["gridview_type"] = "1";
        }

        protected void Button_Others_Click(object sender, EventArgs e)
        {
            dbconn a = new dbconn();
            DataSet ds = new DataSet();
            ds = a.selectdatabase("SELECT Message_ID as 'ID',Message_body as '內容',sender_ID as '發布人',create_time as '創建時間',modify_times as '修改次數',Last_modify_user as '最後修改人' from staff_briefing where msg_type='Others' order by create_time desc", "ps");
            GridView1.DataSource = ds;
            //GridView1.HeaderStyle.Width = "100px";
            GridView1.CellSpacing = 4;
            GridView1.DataBind();
            check_modify();
            next_row_gridview1();

            Session["gridview_type"] = "2";
        }
        protected void Button_Ref_info_Click(object sender, EventArgs e)
        {
            dbconn a = new dbconn();
            DataSet ds = new DataSet();
            ds = a.selectdatabase("SELECT Message_ID as 'ID',Message_body as '內容',sender_ID as '發布人',create_time as '創建時間',modify_times as '修改次數',Last_modify_user as '最後修改人' from staff_briefing where msg_type='Ref_info' order by create_time desc", "ps");
            GridView1.DataSource = ds;
            //GridView1.HeaderStyle.Width = "100px";
            GridView1.CellSpacing = 4;
            GridView1.DataBind();
            check_modify();
            next_row_gridview1();

            Session["gridview_type"] = "3";
        }

    }
}

2个回答

分页哪里不能解析数据库得到的数据

zhhyl
珠海_黄公子 我也不知道问题出哪里,我有2个地方都可以跳转到同一个网页,但是其中有一个地方跳转去以后就不能显示分页了。但是数据正常。就是没有下一页这样!
2 年多之前 回复

我也不知道问题出哪里,我有2个地方都可以跳转到同一个网页,但是其中有一个地方跳转去以后就不能显示分页了。但是数据正常。就是没有下一页这样!

zhhyl
珠海_黄公子 回复AlbertAinstein: anyway thank you .
2 年多之前 回复
zhhyl
珠海_黄公子 回复AlbertAinstein: 这个错误信息有什么办法处理一下么!我连续按2次button之后,正常应该不显示该条信息了,因为button就是读取了的意思,然后不在显示,但是他依然存在然后下面有网页错误信息!但是再按多几次,就会读取了,不再出现该条信息!只是。。。以前按一下就解决的问题!现在按N下!哈哈哈哈。
2 年多之前 回复
AlbertAinstein
AlbertAinstein 从报错信息上说是不能解析服务器上获取的数据
2 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问