示例#1
0
    protected void DataListDataBind()
    {
        //AccessDataSource ads = new AccessDataSource();
        //ads.DataFile = "~/date/blog_Data.mdb";
        //sql_stringchar sql_string = new sql_stringchar();//动态数据源
        //sql_string.connectionstring = sql_string.sql_char;//连接字符串
        Sql_StringChar sql_String = new Sql_StringChar();  //动态数据源

        sql_String.ConnectionString = sql_String.sql_char; //连接字符串
        GetCa_id();
        sql_String.SelectCommand = "SELECT * FROM [blogMessages] where ca_id=" + ca_id + " ";
        DataView        dv      = (DataView)sql_String.Select(DataSourceSelectArguments.Empty);
        PagedDataSource objPage = new PagedDataSource();

        objPage.DataSource  = dv;
        objPage.AllowPaging = true;
        objPage.PageSize    = 3;
        int TolPage;

        TolPage = objPage.PageCount;
        int CurPage;

        if (Request.QueryString["Page"] != null)
        {
            CurPage = Convert.ToInt32(Request.QueryString["Page"]);
        }
        else
        {
            CurPage = 1;
        }
        objPage.CurrentPageIndex = CurPage - 1;
        pagenum.Text             = CurPage.ToString();
        pagecount.Text           = objPage.PageCount + "";
        lnkFirst.NavigateUrl     = Request.CurrentExecutionFilePath + "?Page=1" + "&PageSize=" + Convert.ToString(objPage.PageSize);
        lnkLast.NavigateUrl      = Request.CurrentExecutionFilePath + "?Page=" + TolPage.ToString() + "&PageSize=" + Convert.ToString(objPage.PageSize);
        if (!objPage.IsFirstPage)
        {
            lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage - 1) + "&PageSize=" + Convert.ToString(objPage.PageSize);
        }
        else
        {
            lnkPrev.Visible  = false;
            lnkFirst.Visible = false;
        }
        if (!objPage.IsLastPage)
        {
            lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage + 1) + "&PageSize=" + Convert.ToString(objPage.PageSize);
        }
        else
        {
            lnkNext.Visible = false;
            lnkLast.Visible = false;
        }

        DataList2.DataSource = objPage;
        DataList2.DataBind();
    }
示例#2
0
    protected void DataListDataBind()
    {
        AccessDataSource ads = new AccessDataSource();

        ads.DataFile      = "~/App_Data/mystore.mdb";
        ads.DataFile      = "~/App_Data/mystore.mdb";
        ads.SelectCommand = "SELECT * FROM [Product]";  //ORDER BY [blog_date] DESC
        DataView        dv      = (DataView)ads.Select(DataSourceSelectArguments.Empty);
        PagedDataSource objPage = new PagedDataSource();

        objPage.DataSource  = dv;
        objPage.AllowPaging = true;
        objPage.PageSize    = 9;
        int TolPage;

        TolPage = objPage.PageCount;
        int CurPage;

        if (Request.QueryString["Page"] != null)
        {
            CurPage = Convert.ToInt32(Request.QueryString["Page"]);
        }
        else
        {
            CurPage = 1;
        }
        objPage.CurrentPageIndex = CurPage - 1;
        //pagenum.Text = CurPage.ToString();
        //pagecount.Text = objPage.PageCount + "";
        lnkFirst.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=1" + "&PageSize=" + Convert.ToString(objPage.PageSize);
        lnkLast.NavigateUrl  = Request.CurrentExecutionFilePath + "?Page=" + TolPage.ToString() + "&PageSize=" + Convert.ToString(objPage.PageSize);
        if (!objPage.IsFirstPage)
        {
            lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage - 1) + "&PageSize=" + Convert.ToString(objPage.PageSize);
        }
        else
        {
            lnkPrev.Visible  = false;
            lnkFirst.Visible = false;
        }
        if (!objPage.IsLastPage)
        {
            lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage + 1) + "&PageSize=" + Convert.ToString(objPage.PageSize);
        }
        else
        {
            lnkNext.Visible = false;
            lnkLast.Visible = false;
        }

        DataList1.DataSource = objPage;
        DataList1.DataBind();
    }
示例#3
0
    protected void DataListDataBind()
    {
        try
        {
            //AccessDataSource ads = new AccessDataSource();
            //ads.DataFile = "~/date/blog_Data.mdb";
            Sql_StringChar sql_String = new Sql_StringChar();  //动态数据源
            sql_String.ConnectionString = sql_String.sql_char; //连接字符串
            string year  = Request.QueryString["year"].ToString();
            string month = Request.QueryString["month"].ToString();
            string day   = Request.QueryString["day"].ToString();

            sql_String.SelectCommand = "SELECT * FROM [blogMessages] WHERE day(blog_date)='" + day + "' and month(blog_date)='" + month + "'and year(blog_date)='" + year + "' ORDER BY [blog_date] DESC ";
            DataView        dv      = (DataView)sql_String.Select(DataSourceSelectArguments.Empty);
            PagedDataSource objPage = new PagedDataSource();
            objPage.DataSource  = dv;
            objPage.AllowPaging = true;
            objPage.PageSize    = 4;
            int TolPage;
            TolPage = objPage.PageCount;
            int CurPage;
            if (Request.QueryString["Page"] != null)
            {
                CurPage = Convert.ToInt32(Request.QueryString["Page"]);
            }
            else
            {
                CurPage = 1;
            }
            objPage.CurrentPageIndex = CurPage - 1;
            pagenum.Text             = CurPage.ToString();
            pagecount.Text           = objPage.PageCount + "";
            lnkFirst.NavigateUrl     = Request.CurrentExecutionFilePath + "?Page=1" + "&PageSize=" + Convert.ToString(objPage.PageSize);
            lnkLast.NavigateUrl      = Request.CurrentExecutionFilePath + "?Page=" + TolPage.ToString() + "&PageSize=" + Convert.ToString(objPage.PageSize);
            if (!objPage.IsFirstPage)
            {
                lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage - 1) + "&PageSize=" + Convert.ToString(objPage.PageSize);
            }
            else
            {
                lnkPrev.Visible  = false;
                lnkFirst.Visible = false;
            }
            if (!objPage.IsLastPage)
            {
                lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage + 1) + "&PageSize=" + Convert.ToString(objPage.PageSize);
            }
            else
            {
                lnkNext.Visible = false;
                lnkLast.Visible = false;
            }

            DataList2.DataSource = objPage;
            DataList2.DataBind();
        }
        catch (Exception ee)
        {
            Response.Redirect("_boke.aspx");
        }
    }
示例#4
0
    protected void DataListDataBind()
    {
        Sql_StringChar sql_String = new Sql_StringChar();  //动态数据源

        sql_String.ConnectionString = sql_String.sql_char; //连接字符串
        sql_String.SelectCommand    = "SELECT * FROM [blogMessages]  ORDER BY [blog_date] DESC ";
        DataView        dv      = (DataView)sql_String.Select(DataSourceSelectArguments.Empty);
        PagedDataSource objPage = new PagedDataSource();

        objPage.DataSource  = dv;
        objPage.AllowPaging = true;
        objPage.PageSize    = 10;
        int TolPage;

        TolPage = objPage.PageCount;
        int CurPage;

        if (Request.QueryString["Page"] != null)
        {
            CurPage = Convert.ToInt32(Request.QueryString["Page"]);
        }
        else
        {
            CurPage = 1;
        }
        objPage.CurrentPageIndex = CurPage - 1;
        pagenum.Text             = CurPage.ToString();
        pagecount.Text           = objPage.PageCount + "";
        lnkFirst.NavigateUrl     = Request.CurrentExecutionFilePath + "?Page=1" + "&PageSize=" + Convert.ToString(objPage.PageSize);
        lnkLast.NavigateUrl      = Request.CurrentExecutionFilePath + "?Page=" + TolPage.ToString() + "&PageSize=" + Convert.ToString(objPage.PageSize);
        if (!objPage.IsFirstPage)
        {
            lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage - 1) + "&PageSize=" + Convert.ToString(objPage.PageSize);
        }
        else
        {
            lnkPrev.Visible  = false;
            lnkFirst.Visible = false;
        }
        if (!objPage.IsLastPage)
        {
            lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage + 1) + "&PageSize=" + Convert.ToString(objPage.PageSize);
        }
        else
        {
            lnkNext.Visible = false;
            lnkLast.Visible = false;
        }
        sql_String.Dispose();
        DataList2.DataSource = objPage;
        DataList2.DataBind();
        #region/******************千万不能删************************/
        //get评论数
        //string j = string.Empty;
        //for (int i = 0; i < DataList2.Items.Count; i++)
        //{
        //    j = ((Label)DataList2.Items[i].FindControl("Label12")).Text;
        //    string sql_char = "server=.;Initial Catalog=Blog_wwww;User ID=sa;Password=1";//连接字符串
        //    string sql = "SELECT  count(blog_id)  FROM [blogComments] WHERE BLOG_ID='" + j + "'";
        //    using (SqlConnection conn = new SqlConnection(sql_char))
        //    {
        //        conn.Open();
        //        using (SqlCommand cmd = conn.CreateCommand())
        //        {
        //            string k = conn.State.ToString();
        //            cmd.CommandText = sql;

        //            //if (cmd.ExecuteReader() > 0)
        //            //{
        //            //}
        //            int n = cmd.ExecuteNonQuery();
        //            using (SqlDataReader dr = cmd.ExecuteReader())
        //            {
        //                //string k=dr[""]
        //            }
        //        }
        //    }
        //}
        #endregion /******************千万不能删************************/
    }
示例#5
0
    protected void DataListDataBind()
    {
        //AccessDataSource ads = new AccessDataSource();
        //ads.DataFile = "~/date/blog_Data.mdb";

        //SqlDataSource srcMov = new SqlDataSource();
        //srcMov.ConnectionString =
        //     WebConfigurationManager.ConnectionStrings["DawnEnterpriseDBConnectionString"].ConnectionString;
        //SqlDataSource ads = new SqlDataSource();
        //ads.ConnectionString = "server=.;Initial Catalog=Blog_wwww;User ID=sa;Password=1";

        Sql_StringChar sql_String = new Sql_StringChar();  //动态数据源

        sql_String.ConnectionString = sql_String.sql_char; //连接字符串
        sql_String.SelectCommand    = "SELECT * FROM [blogMessages]  ORDER BY [blog_date] DESC ";


        DataView        dv      = (DataView)sql_String.Select(DataSourceSelectArguments.Empty);
        PagedDataSource objPage = new PagedDataSource();

        objPage.DataSource  = dv;
        objPage.AllowPaging = true;
        objPage.PageSize    = 5;
        int TolPage;

        TolPage = objPage.PageCount;
        int CurPage;

        if (Request.QueryString["Page"] != null)
        {
            CurPage = Convert.ToInt32(Request.QueryString["Page"]);
        }
        else
        {
            CurPage = 1;
        }
        objPage.CurrentPageIndex = CurPage - 1;
        //pagenum.Text = CurPage.ToString();
        //pagecount.Text = objPage.PageCount + "";
        lnkFirst.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=1" + "&PageSize=" + Convert.ToString(objPage.PageSize);
        lnkLast.NavigateUrl  = Request.CurrentExecutionFilePath + "?Page=" + TolPage.ToString() + "&PageSize=" + Convert.ToString(objPage.PageSize);
        if (!objPage.IsFirstPage)
        {
            lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage - 1) + "&PageSize=" + Convert.ToString(objPage.PageSize);
        }
        else
        {
            lnkPrev.Visible = false;


            lnkFirst.Visible = false;
        }
        if (!objPage.IsLastPage)
        {
            lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage + 1) + "&PageSize=" + Convert.ToString(objPage.PageSize);
        }
        else
        {
            lnkNext.Visible = false;
            lnkLast.Visible = false;
        }
        FormView1.DataSource = objPage;
        FormView1.DataBind();
        // DataList1.DataSource = objPage;
        //DataList1.DataBind();
    }