⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lyb.aspx.cs

📁 大家一起研究研究,全部都是开源的CSHARP代码.带数据库的
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
//该源码下载自www.51aspx.com(51aspx.com)

public partial class Lyb : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.TextBox3.Text = WebConfig.IPAddress;
            string sql = "select * from [NcLy] Order By [LyId] DESC";
            WebConfig.CreateCon();
            OleDbDataAdapter da = new OleDbDataAdapter(sql, WebConfig.con);
            DataSet ds = new DataSet();
            da.Fill(ds);
            DataTable dt = ds.Tables[0];
            if (dt.Rows.Count > 0)
            {
                PagedDataSource pds = new PagedDataSource();
                pds.DataSource = ds.Tables[0].DefaultView;

                pds.AllowPaging = true;
                pds.PageSize = Convert.ToInt32(Application["LiuYanSize"]);
                int curPage;

                if (Request.QueryString["page"] != null)
                {
                    curPage = Convert.ToInt32(Request.QueryString["page"]);
                }
                else
                {
                    curPage = 1;
                }


                pds.CurrentPageIndex = curPage - 1;
                this.Repeater1.DataSource = pds;
                this.Repeater1.DataBind();
                this.Label1.Text += "<a>共有" + ds.Tables[0].Rows.Count.ToString() + "条留言</a>&nbsp;&nbsp;";
                this.Label1.Text += "<a>分" + pds.PageCount.ToString() + "页</a>&nbsp;&nbsp;";
                this.Label1.Text += "<a>第" + curPage.ToString() + "页</a>&nbsp;&nbsp;";
                //this.LbNewsCount.Text = ds.Tables[0].Rows.Count.ToString();
                //this.LbPageCount.Text = pds.PageCount.ToString();
                //this.LbCurPage.Text = curPage.ToString();
                if (curPage == 1)
                {
                    this.Label1.Text += "<a>上一页</a>&nbsp;&nbsp;";
                }
                else
                {
                    this.Label1.Text += "<a href='Lyb.aspx?page=" + (curPage - 1).ToString() + "'>上一页</a>&nbsp;&nbsp;";
                }
                if (curPage == pds.PageCount)
                {
                    this.Label1.Text += "<a>下一页</a>";
                }
                else
                {
                    this.Label1.Text += "<a href='Lyb.aspx?page=" + (curPage + 1).ToString() + "'>下一页</a>";
                }
            }
            else
            {
                this.Label1.Text = "当前没有留言";
            }
            ds.Dispose();
            da.Dispose();
            WebConfig.CloseCon();


        }
    }


    protected void Button1_Click(object sender, EventArgs e)
    {
        string sql = "insert into [NcLy] ([LyC],[LyDate],[LyIp],[LyAUthor]) Values ('" + TextBox2.Text +"','"+DateTime.Now+"','"+TextBox3.Text+"','"+TextBox1.Text+"')";
        WebConfig.CreateCon();
        OleDbCommand cmd = new OleDbCommand(sql, WebConfig.con);
        cmd.ExecuteNonQuery();
        Response.Write("<script>alert('发表留言成功!');location.href='Lyb.aspx';</script>");
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -