Default.aspx.cs

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Data;
using System.Configuration;
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.SqlClient;

public partial class _Default : System.Web.UI.Page 
{
    string curPage;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.lblPageCur.Text = "1";//不能放到dataGridBind()后面,不然lblPageCur.Text没有被初始化,出错
            dataGridBind();            
        }
    }
    public void dataGridBind()
    {        
        curPage =this.lblPageCur.Text;
        SqlConnection conn = DB.createCon();
        SqlCommand cmd = new SqlCommand();
        cmd.CommandText = "select * from guest";
        cmd.Connection = conn;
        SqlDataAdapter sda = new SqlDataAdapter();
        sda.SelectCommand = cmd;
        DataSet ds = new DataSet();
        sda.Fill(ds, "guest");
        PagedDataSource pds = new PagedDataSource();
        pds.AllowPaging = true;
        pds.PageSize = 3;
        pds.DataSource = ds.Tables["guest"].DefaultView;
        pds.CurrentPageIndex = Convert.ToInt32(curPage) - 1;
        this.lblPageTotal.Text = pds.PageCount.ToString();
        this.Button1.Enabled=true;
        this.Button2.Enabled=true;
        if (curPage == "1")
        {
            this.Button1.Enabled = false;
        }            
        if (curPage == pds.PageCount.ToString())
        {
            this.Button2.Enabled = false;
        }
        this.DataList1.DataSource = pds;
        this.DataList1.DataBind();

        cmd.CommandText = "select count(*) from guest";
        this.lblMesTotal.Text = Convert.ToString(cmd.ExecuteScalar());

        int a = pds.PageCount;
        for(int i=1;i<=a;i++)
        {
            this.DropDownList1.Items.Add(i.ToString());
        }
后面还有 77 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。