First of all, I added the previous published: When you use the user control I have made in your creation: State Protected DataGridPage1 As DataGridPage, the previous control name you dragged in, after you Define user controls. Then use your control in your code:
DataGridPage1.SetTarget (MyDataGrid, New Binddata) DataGridpage1.setStyle (10, FALSE)
The underscore section is a mandatory of a binding of yourself. Sub, Function, etc.
The following is the code when I don't do control:
HTML:
<% @ Page language = "vb" autoeventwireup = "false" codebehind = "flye.aspx.vb" inherits = "DataGridtitle.fenye"%>
Z-Index: 104; Left: 120px; Position: absolute; top: 96px "Runat =" server "width =" 48px "> Rear page asp: linkbutton>
Private sub page_load (byval sender as system.Object, byval e as system.eventargs) Handles mybase.load 'ペ ペ ジ を 初 化 化 ユ ユ ザ ザ コ ド を ここ に し ま ま. ま ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユIF not ispostback.
ViewState ("strsort") = "ORDERID" mydatagrid.datasource = getdv (ViewState ("strsort"). Tostring ())
MyDataGrid.Database () showstatspage () 'call orderbind () enddiff (byval strsrt as string) AS dataView
DIM DV AS DATAVIEW
DIM CN AS New SqlConnection
Try
Cn.connectionstring = "data source = yangchangquan; initial catalog = northwind; persist security info = false; user id = sa; password = pass;"
Cn.open ()
DIM ADP As SqldataAdapter = New Sqldataadapter ("Select * from Orders", CN)
DIM DS AS New DataSet
ADP.FILL (DS)
DV = ds.tables (0) .defaultview
Catch exception
#If debug the
Session ("error") = ex.toString ()
Response.Redirect ("../ error.aspx")
#End IF
Finally
'???
Cn.close ()
END TRY
'Sort
Dv.sort = strsort
Return DV
END FUNCTION
Private sub mydatagrid_sortcommand (Byval Source as system.Object, byval e as system.Web.ui.WebControls.DataGridsortCommandeventAgs) MyDataGrid.currentpageIndex = 0
'Get the column
ViewState ("strsort") = E.Sortexpression.toString ()
MyDataGrid.datasource = getDV (ViewState ("strsort"). TOSTRING ())
MyDataGrid.Database
Showstatspage () End Sub
Private Sub btnGo_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click Dim pageI As Integer If (txtGoPage.Text <> "") Then pageI = CInt (Trim (txtGoPage.Text)) - 1 If (pageI> = 0 And pageI <(MyDataGrid.PageCount)) Then MyDataGrid.CurrentPageIndex = pageI End If End If ViewState ( "strSort") = "orderid" MyDataGrid.DataSource = GetDv (ViewState ( "strSort"). ToString ( ))
MyDataGrid.Database () showstatspage () end sub
Private Sub showstatspage () lblcurrentindex.text = "[ The current page is:" & (MyDataGrid.currentpageIndex 1) & "page font>]" lblpagecount.text = "[ A total of: "& myDataGrid.pagecount &" page font>] "
End Sub
Private sub linebutton1_click (byval e as system.EventArgs) handles linkbutton1.click mydatagrid.currentpageindex = 0 viewState ("strsort") = "OrderID"
MyDataGrid.datasource = getDV (ViewState ("strsort"). TOSTRING ())
MyDataGrid.Database () showstatspage () end sub
Private Sub LinkButton4_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkButton4.Click MyDataGrid.CurrentPageIndex = (MyDataGrid.PageCount - 1) ViewState ( "strSort") = "orderid"
MyDataGrid.datasource = getDV (ViewState ("strsort"). TOSTRING ())
MyDataGrid.Database () showstatspage () end sub
Private Sub LinkButton2_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkButton2.Click If (MyDataGrid.CurrentPageIndex> 0) Then MyDataGrid.CurrentPageIndex = MyDataGrid.CurrentPageIndex - 1 ViewState ( "strSort") = "orderid" MyDataGrid.datasource = getDV (ViewState ("strsort"). TOSTRING ())
MyDataGrid.Database () showstatspage () end if End Sub
Private Sub LinkButton3_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkButton3.Click If (MyDataGrid.CurrentPageIndex <(MyDataGrid.PageCount - 1)) Then MyDataGrid.CurrentPageIndex = MyDataGrid.CurrentPageIndex 1 ViewState ( "strSort ") =" OrderID "
MyDataGrid.datasource = getDV (ViewState ("strsort"). TOSTRING ())
MyDataGrid.Database () showstatspage () end if End Sub
carry out;