关键是用SqlDataAdapter如何来加这个@customerid参数的,“cmd_prev.Parameters("@customerid").Value = FirstID”它用的是command对象,换成SqlDataAdapter怎么办呀??还有,想看CSDN上以前的帖子,怎么看呀,现在就能看到最新的300条,其余的呢??
解决方案 »
- jquery post返回json大小问题
- 如何将输入文本框的邮箱地址转变成图片?
- 网站下载数据表
- 怎么把页面上录入的信息在按了提交按钮后存入到数据库的表中?
- 各位高手,帮帮忙!~~急啊~~~数据库连接问题.
- 一个简单的问题,但是我不记得怎么做了:如何获得当前时间?
- 请问怎样在DataGrid中某列的值可以象这样<a href=sound.aspx?<%# DataBinder.Eval(Container.DataItem,"[\"name\"]")%>>列名</a>
- Asp.net2.0如何实现有主、明细表的单据
- 帮忙看看
- 动态添加模板列的问题,急,等。。。。。。
- 在线等待,
- 在web.config 中配置,限定用户必须从首页进行访问。怎么做?
学习一下。
学习一下。
Imports System.Data
Imports System.Web.UIPublic Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid
Protected WithEvents btnFirst As System.Web.UI.WebControls.LinkButton
Protected WithEvents btnPrev As System.Web.UI.WebControls.LinkButton
Protected WithEvents btnNext As System.Web.UI.WebControls.LinkButton
Protected WithEvents btnLast As System.Web.UI.WebControls.LinkButton
Protected WithEvents lblCurrentIndex As System.Web.UI.WebControls.Label
Protected WithEvents lblPageCount As System.Web.UI.WebControls.Label
Protected WithEvents MyDataGrid As System.Web.UI.WebControls.DataGrid
#Region " Web 窗体设计器生成的代码 " '该调用是 Web 窗体设计器所必需的。
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() End Sub 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
btnFirst.Text = "最首页"
btnPrev.Text = "前一页"
btnNext.Text = "下一页"
btnLast.Text = "最后页"
OpenDatabase()
BindGrid()
End Sub
Sub MyDataGrid_Page(ByVal sender As Object, ByVal e As DataGridPageChangedEventArgs)
Dim startIndex As Integer
startIndex = MyDataGrid.CurrentPageIndex * MyDataGrid.PageSize
MyDataGrid.CurrentPageIndex = e.NewPageIndex
BindGrid()
ShowStats()
End Sub Sub BindGrid()
Dim myConnection As SqlConnection = cn
Dim ds As DataSet = New DataSet()
Dim adapter As SqlDataAdapter = New SqlDataAdapter("Select * from Orders", myConnection)
adapter.Fill(ds, "Orders")
MyDataGrid.DataSource = ds.Tables("Orders").DefaultView
MyDataGrid.DataBind()
ShowStats() End Sub Sub PagerButtonClick(ByVal sender As Object, ByVal e As EventArgs)
'used by external paging UI
Dim arg As String = sender.CommandArgument Select Case arg
Case "next"
If (MyDataGrid.CurrentPageIndex < (MyDataGrid.PageCount - 1)) Then
MyDataGrid.CurrentPageIndex += 1
End If
Case "prev"
If (MyDataGrid.CurrentPageIndex > 0) Then
MyDataGrid.CurrentPageIndex -= 1
End If
Case "last"
MyDataGrid.CurrentPageIndex = (MyDataGrid.PageCount - 1)
Case Else
'page number
MyDataGrid.CurrentPageIndex = System.Convert.ToInt32(arg)
End Select
BindGrid()
ShowStats()
End Sub Sub ShowStats()
lblCurrentIndex.Text = "第 " + (MyDataGrid.CurrentPageIndex + 1).ToString() + " 页"
lblPageCount.Text = "总共 " + MyDataGrid.PageCount.ToString() + " 页"
End Sub
Public cn As New SqlClient.SqlConnection()
Public Sub OpenDatabase()
cn.ConnectionString = "Server=hqeipmisdbsvr11;Database=NorthWind;User Id=sa;Password=;"
cn.Open()
End SubEnd Class