📄 admin_top_list.aspx.vb
字号:
'因为用到了自定义业务对象,所以导入
Public Class admin_top_list
Inherits System.Web.UI.Page
#Region " Web 窗体设计器生成的代码 "
'该调用是 Web 窗体设计器所必需的。
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents myDataGrid As System.Web.UI.WebControls.DataGrid
Protected WithEvents Form1 As System.Web.UI.HtmlControls.HtmlForm
'注意: 以下占位符声明是 Web 窗体设计器所必需的。
'不要删除或移动它。
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
'不要使用代码编辑器修改它。
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
'判断一下,如果不是管理员,就返回到首页
If DataUserLog.IsAdmin() = False Then
Response.Write("<script language='javascript'>top.location.href='../index.aspx';</script>")
End If
If Not Page.IsPostBack Then
Call myDataBind() '绑定数据
End If
End Sub
'该过程用于置顶或取消置顶
Private Sub myDataGrid_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles myDataGrid.ItemCommand
'必须加这个判断,否则切换页面时也会先触发该过程并执行下面的语句,就会产生错误
If e.CommandName = "AddSetTop" Then
Dim dbs As New DataBusiness
Call dbs.AddSetTop(myDataGrid.DataKeys(e.Item.ItemIndex))
'重新绑定数据
Call myDataBind()
End If
End Sub
'该过程用于分页
Private Sub myDataGrid_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles myDataGrid.PageIndexChanged
myDataGrid.CurrentPageIndex = e.NewPageIndex
Call myDataBind() '绑定数据
End Sub
'该过程用于绑定数据
Sub myDataBind()
'下面建立DataBusiness对象,返回所有文章
Dim dbs As New DataBusiness
Dim dv As DataView = dbs.GetBBS()
dv.RowFilter = "Layer=1" '这里原来返回的是所有文章,这里只要第1层文章
'下面绑定数据
myDataGrid.DataSource = dv
myDataGrid.DataBind()
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -