日期:2013-02-14  浏览次数:20431 次

首先对我之前的发表的那篇补充一下:当你在你的建立的工程中要用到我做的那个用户控件的话:声明 Protected DataGridPage1 As DataGridPage,前是你拖进来的控件名,后是你定义用户控件。然后在你代码中要用你的控件就写上:

DataGridPage1.SetTarget(MyDataGrid, New BindDataDelegate(AddressOf binddata))
DataGridPage1.SetStyle(10, False)

下划线部分是你自己写的一个绑定之类的涵数。SUB,FUNCTION 等。

以下是我不做成控件时的代码:

HTML:

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="fenye.aspx.vb" Inherits="datagridtitle.fenye"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>fenye</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="MS UI Gothic">
<asp:DataGrid id="MyDataGrid" style="Z-INDEX: 101; LEFT: 0px; POSITION: absolute; TOP: 112px"
runat="server" Width="744px" Height="224px" AllowPaging="True">
<PagerStyle Visible="False"></PagerStyle>
</asp:DataGrid>
<asp:LinkButton id="LinkButton1" style="Z-INDEX: 102; LEFT: 8px; POSITION: absolute; TOP: 96px"
runat="server" Width="48px" Height="8px">第一頁</asp:LinkButton>
<asp:LinkButton id="LinkButton2" style="Z-INDEX: 103; LEFT: 64px; POSITION: absolute; TOP: 96px"
runat="server" Width="56px">前一頁</asp:LinkButton>
<asp:LinkButton id="LinkButton3" style="Z-INDEX: 104; LEFT: 120px; POSITION: absolute; TOP: 96px"
runat="server" Width="48px">後一頁</asp:LinkButton>
<asp:LinkButton id="LinkButton4" style="Z-INDEX: 105; LEFT: 176px; POSITION: absolute; TOP: 96px"
runat="server" Width="80px">最後一頁</asp:LinkButton>
<asp:Label id="Label1" style="Z-INDEX: 106; LEFT: 552px; POSITION: absolute; TOP: 80px" runat="server"
Width="56px">跳轉到:</asp:Label>
<asp:TextBox id="txtGoPage" style="Z-INDEX: 107; LEFT: 624px; POSITION: absolute; TOP: 80px"
runat="server" Width="48px" Height="24px"></asp:TextBox>
<asp:Button id="btnGo" style="Z-INDEX: 108; LEFT: 680px; POSITION: absolute; TOP: 80px" runat="server"
Height="24px" Width="56px" Text="Button"></asp:Button>
<asp:Label id="lblCurrentIndex" style="Z-INDEX: 109; LEFT: 296px; POSITION: absolute; TOP: 88px"
runat="server" Height="24px" Width="120px">Label</asp:Label>
<asp:Label id="lblPageCount" style="Z-INDEX: 110; LEFT: 424px; POSITION: absolute; TOP: 88px"
runat="server" Width="112px">Label</asp:Label></FONT>
</form>
</body>
</HTML>


WEB代码:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' ページを初期化するユーザー コードをここに挿入します。
If Not IsPostBack Then

ViewState("strSort") = "orderid"