manadp = New SqlClient.SqlDataAdapter
manadp.SelectCommand = objcomd
mands = New DataSet
//填充DataSet数据集
manadp.Fill(mands, "mana")
//设置分页显示试题的数量
Dim manpd As PagedDataSource = New PagedDataSource
manpd.DataSource = mands.Tables("mana").DefaultView()
manpd.AllowPaging = True
manpd.PageSize = 4
//定义当前页变量CurPage
Dim CurPage As Integer
//设置当前页的页码索引为当前页码减一
manpd.CurrentPageIndex = CurPage - 1
lblCurrentPage2.Text = " <共:" & CurPage.ToString() & "/" & manpd.PageCount & "页>"
//如果是上一页,跳转到前一页
If Not manpd.IsFirstPage Then
lnkPrev2.NavigateUrl = Request.CurrentExecutionFilePath & "?Page=" & Convert.ToString(CurPage - 1) & "&mana=" & Server.UrlEncode(Session("mana")) & ""
lnkFirst2.NavigateUrl = Request.CurrentExecutionFilePath & "?Page=1" & "&mana=" & Server.UrlEncode(Session("mana")) & ""
End If
//如果是下一页,跳转到后一页
If Not manpd.IsLastPage Then
lnkNext2.NavigateUrl = Request.CurrentExecutionFilePath & "?Page=" & Convert.ToString(CurPage + 1) & "&mana=" & Server.UrlEncode(Session("mana")) & ""
lnkLast2.NavigateUrl = Request.CurrentExecutionFilePath & "?Page=" & manpd.PageCount & "&mana=" & Server.UrlEncode(Session("mana")) & ""
End If
4.5.1 添加、修改试题页面(addquestion/)
添加和修改试题共用一个页面,在执行不同操作时,传递不同的参数edittest,当edittest为空值时,显示添加试题页面,不为空显示为修改试题页面,并根据参数所传递的ID号来绑定数据库中的对应的试题信息,显示在相应的下拉列表、文本框或单选按钮上。如图4-5所示:
图4-5 修改试题
关键代码解释:
//使用Request对象的QueryString属性来获取edittest参数的值
edittest = Request.QueryString("edittest")
If edittest <> "" Then
comdstr = "select * from question where id=" & edittest
objcomd = New SqlCommand(comdstr, conn)
objcomd.Connection.Open()
testdr = objcomd.ExecuteReader
If testdr.Read() Then
txtquestion.Text = testdr("question").ToString
txtA.Text = testdr("A").ToString
txtB.Text = testdr("B").ToString
txtC.Text = testdr("C").ToString
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说计算机基于B/S的网上考试系统的设计与实现(9)在线全文阅读。
相关推荐: