关键字:
wap分页
list分页
简介:看到LIST在手机上显示的分页效果,我个人感觉特别不满,随手写了一个用户控件与大家分享,有补充之处请您修整留言.
aspx代码
引用页aspx代码
引用页 VB代码
wap分页
list分页
简介:看到LIST在手机上显示的分页效果,我个人感觉特别不满,随手写了一个用户控件与大家分享,有补充之处请您修整留言.
aspx代码
1
<%@ Control Language="vb" AutoEventWireup="false" Codebehind="BestList.ascx.vb" Inherits="MoaWap.BestList" TargetSchema="http://schemas.microsoft.com/Mobile/WebUserControl" %>
2
<%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %>
3
<mobile:list id="list" Decoration="Bulleted" runat="server"></mobile:list>
4
<mobile:Panel id="Panel1" runat="server" BreakAfter="True">
5
<mobile:Label id="Label1" runat="server" BreakAfter="False">[</mobile:Label>
6
<mobile:Label id="lbl_currpage" runat="server" BreakAfter="False">1</mobile:Label>
7
<mobile:Label id="Label2" runat="server" BreakAfter="False">/</mobile:Label>
8
<mobile:Label id="lbl_count" runat="server" BreakAfter="False">0</mobile:Label>
9
<mobile:Label id="Label3" runat="server" BreakAfter="False">] </mobile:Label>
10
<mobile:Label id="lbl_RoteCount" runat="server" BreakAfter="False">0</mobile:Label>
11
<mobile:Label id="Label5" runat="server" BreakAfter="False">条记录</mobile:Label>
12
</mobile:Panel>
13
<mobile:Panel id="Panel2" runat="server" BreakAfter="True">
14
<mobile:Command id="btn_first" runat="server" BreakAfter="False" Visible="False">[首页]</mobile:Command>
15
<mobile:command id="btn_syy" runat="server" BreakAfter="False" Visible="False">[上页]</mobile:command>
16
<mobile:command id="btn_xyy" runat="server" BreakAfter="False" Visible="False">[下页]</mobile:command>
17
<mobile:Command id="btn_end" runat="server" BreakAfter="False" Visible="False">[末页]</mobile:Command>
18
</mobile:Panel>
19
<mobile:Panel id="Panel3" runat="server">
20
<mobile:Label id="Label4" runat="server" BreakAfter="False">转向</mobile:Label>
21
<mobile:TextBox id="txt_go" runat="server" BreakAfter="False" Numeric="True" Size="2">1</mobile:TextBox>
22
<mobile:Command id="btn_go" runat="server" BreakAfter="False">GO</mobile:Command>
23
</mobile:Panel>
24
<mobile:Label id="lbl_index" runat="server" Visible="False">0</mobile:Label>
vb代码
<%@ Control Language="vb" AutoEventWireup="false" Codebehind="BestList.ascx.vb" Inherits="MoaWap.BestList" TargetSchema="http://schemas.microsoft.com/Mobile/WebUserControl" %>2
<%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %>3
<mobile:list id="list" Decoration="Bulleted" runat="server"></mobile:list>4
<mobile:Panel id="Panel1" runat="server" BreakAfter="True">5
<mobile:Label id="Label1" runat="server" BreakAfter="False">[</mobile:Label>6
<mobile:Label id="lbl_currpage" runat="server" BreakAfter="False">1</mobile:Label>7
<mobile:Label id="Label2" runat="server" BreakAfter="False">/</mobile:Label>8
<mobile:Label id="lbl_count" runat="server" BreakAfter="False">0</mobile:Label>9
<mobile:Label id="Label3" runat="server" BreakAfter="False">] </mobile:Label>10
<mobile:Label id="lbl_RoteCount" runat="server" BreakAfter="False">0</mobile:Label>11
<mobile:Label id="Label5" runat="server" BreakAfter="False">条记录</mobile:Label>12
</mobile:Panel>13
<mobile:Panel id="Panel2" runat="server" BreakAfter="True">14
<mobile:Command id="btn_first" runat="server" BreakAfter="False" Visible="False">[首页]</mobile:Command>15
<mobile:command id="btn_syy" runat="server" BreakAfter="False" Visible="False">[上页]</mobile:command>16
<mobile:command id="btn_xyy" runat="server" BreakAfter="False" Visible="False">[下页]</mobile:command>17
<mobile:Command id="btn_end" runat="server" BreakAfter="False" Visible="False">[末页]</mobile:Command>18
</mobile:Panel>19
<mobile:Panel id="Panel3" runat="server">20
<mobile:Label id="Label4" runat="server" BreakAfter="False">转向</mobile:Label>21
<mobile:TextBox id="txt_go" runat="server" BreakAfter="False" Numeric="True" Size="2">1</mobile:TextBox>22
<mobile:Command id="btn_go" runat="server" BreakAfter="False">GO</mobile:Command>23
</mobile:Panel>24
<mobile:Label id="lbl_index" runat="server" Visible="False">0</mobile:Label> 1
Imports System.Web.UI.MobileControls
2
3
委托定义
7
8
Public MustInherit Class BestList
9
Inherits System.Web.UI.MobileControls.MobileUserControl
10
11
Web 窗体设计器生成的代码
48
49
变量及事件声明
55
56
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
57
'在此处放置初始化页的用户代码
58
End Sub
59
60
属性定义
139
140
'''<summary>
141
'''列表框复位
142
'''</summary>
143
Public Sub ItemClear()
144
list.Items.Clear()
145
list.DataSource = Nothing
146
list.DataTextField = ""
147
list.DataValueField = ""
148
lbl_index.Text = "0"
149
lbl_currpage.Text = "1"
150
End Sub
151
152
'''ItemCommand事件激活
153
Private Sub list_ItemCommand(ByVal sender As Object, ByVal e As System.Web.UI.MobileControls.ListCommandEventArgs) Handles list.ItemCommand
154
lbl_index.Text = e.ListItem.Index.ToString()
155
'If Not (BestListItemCommand Is Nothing) Then
156
RaiseEvent BestListItemCommand(sender, e)
157
'End If
158
End Sub
159
160
'''<summary>
161
''' 数据绑定
162
''' </summary>
163
Public Sub DataBindList()
164
If Not (MyDataSoune Is Nothing) Then
165
'得出当前记录总数
166
Dim RoteCount As Integer = MyDataSoune.Rows.Count
167
'当不同数据源绑定时恢复当前页为1(根据记录数判断是否是同一个数据源)
168
Dim OldRoteCount As Integer = Convert.ToInt32(lbl_RoteCount.Text.Trim())
169
If OldRoteCount <> 0 And OldRoteCount <> RoteCount Then
170
lbl_currpage.Text = "1"
171
End If
172
lbl_RoteCount.Text = RoteCount.ToString()
173
'得出页总数
Dim tespint As Integer = RoteCount Mod PageSize
If tespint > 0 Then
'lbl_count.Text = Convert.ToString(CInt(RoteCount / PageSize) + 1)
lbl_count.Text = Convert.ToString(CInt((RoteCount - tespint) / PageSize) + 1)
176
Else
177
lbl_count.Text = Convert.ToString(RoteCount / PageSize)
178
End If
179
If Convert.ToInt32(lbl_currpage.Text.Trim()) > 0 And Convert.ToInt32(lbl_currpage.Text.Trim()) <= Convert.ToInt32(lbl_count.Text.Trim()) Then
180
'据当前页求出本页的开始记录和结束记录索引
181
Dim start As Integer, tempend As Integer
182
start = (Convert.ToInt32(lbl_currpage.Text.Trim()) - 1) * PageSize
183
If Convert.ToInt32(lbl_currpage.Text.Trim()) = Convert.ToInt32(lbl_count.Text.Trim()) Then
184
tempend = RoteCount - 1
185
Else
186
tempend = start + PageSize - 1
187
End If
188
list.Items.Clear()
189
For i As Integer = start To tempend
190
'初始化列表框
191
Dim MyList As New MobileListItem
192
MyList.Value = MyDataSoune.Rows(i)(list.DataValueField.Trim()).ToString()
193
MyList.Text = MyDataSoune.Rows(i)(list.DataTextField.Trim()).ToString()
194
list.Items.Add(MyList)
195
Next
196
197
End If
198
'---------导航按钮控制
199
If Convert.ToInt32(lbl_count.Text.Trim()) <= 1 Then
200
'当只有一页时或没有记录时
201
btn_first.Visible = False
202
btn_syy.Visible = False
203
btn_xyy.Visible = False
204
btn_end.Visible = False
205
Panel1.Visible = False
206
ElseIf Convert.ToInt32(lbl_currpage.Text.Trim()) = 1 Then
207
'当为第一页时
208
btn_first.Visible = False
209
btn_syy.Visible = False
210
btn_xyy.Visible = True
211
btn_end.Visible = True
212
Panel1.Visible = True
213
ElseIf Convert.ToInt32(lbl_currpage.Text.Trim()) = Convert.ToInt32(lbl_count.Text.Trim()) Then
214
'当为最后一页时
215
btn_first.Visible = True
216
btn_syy.Visible = True
217
btn_xyy.Visible = False
218
btn_end.Visible = False
219
Panel1.Visible = True
220
ElseIf Convert.ToInt32(lbl_currpage.Text.Trim()) = 2 Then
221
'当为第二页时
222
btn_first.Visible = True
223
btn_syy.Visible = False
224
btn_xyy.Visible = True
225
btn_end.Visible = True
226
Panel1.Visible = True
227
ElseIf Convert.ToInt32(lbl_currpage.Text.Trim()) = Convert.ToInt32(lbl_count.Text.Trim()) - 1 Then
228
'当为最后一页时
229
btn_first.Visible = True
230
btn_syy.Visible = True
231
btn_xyy.Visible = False
232
btn_end.Visible = True
233
Panel1.Visible = True
234
Else
235
btn_first.Visible = True
236
btn_syy.Visible = True
237
btn_xyy.Visible = True
238
btn_end.Visible = True
239
Panel1.Visible = True
240
End If
241
End If
242
End Sub
243
244
'''翻页处理
245
Private Sub MyPageIdexChange(ByVal key As String)
246
Select Case key
247
Case "first"
248
If Convert.ToInt32(lbl_count.Text.Trim()) > 0 Then
249
lbl_currpage.Text = "1"
250
End If
251
Case "top"
252
If Convert.ToInt32(lbl_currpage.Text.Trim()) > 1 Then
253
lbl_currpage.Text = Convert.ToString(Convert.ToInt32(lbl_currpage.Text.Trim()) - 1)
254
End If
255
Case "next"
256
If Convert.ToInt32(lbl_currpage.Text.Trim()) < Convert.ToInt32(lbl_count.Text.Trim()) Then
257
lbl_currpage.Text = Convert.ToString(Convert.ToInt32(lbl_currpage.Text.Trim()) + 1)
258
End If
259
Case "last"
260
If Convert.ToInt32(lbl_count.Text.Trim()) > 0 Then
261
lbl_currpage.Text = lbl_count.Text.Trim()
262
End If
263
Case "go"
264
If txt_go.Text.Trim() <> "" Then
265
Dim igo As Integer = CInt(txt_go.Text.Trim())
266
If igo <= Convert.ToInt32(lbl_count.Text.Trim()) And igo >= 1 Then
267
lbl_currpage.Text = txt_go.Text.Trim()
268
End If
269
End If
270
End Select
271
'触发用户控件的PageIdexChange事件
272
'If Not (BestListPageIndexChange Is Nothing) Then
273
RaiseEvent BestListPageIndexChange(Me)
274
'End If
275
End Sub
276
277
278
Private Sub btn_first_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_first.Click
279
MyPageIdexChange("first")
280
End Sub
281
282
Private Sub btn_syy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_syy.Click
283
MyPageIdexChange("top")
284
End Sub
285
286
Private Sub btn_xyy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_xyy.Click
287
MyPageIdexChange("next")
288
End Sub
289
290
Private Sub btn_end_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_end.Click
291
MyPageIdexChange("last")
292
End Sub
293
294
Private Sub btn_go_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_go.Click
295
MyPageIdexChange("go")
296
End Sub
297
End Class
298
Imports System.Web.UI.MobileControls2

3
委托定义7

8
Public MustInherit Class BestList9
Inherits System.Web.UI.MobileControls.MobileUserControl10

11
Web 窗体设计器生成的代码48

49
变量及事件声明55

56
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load57
'在此处放置初始化页的用户代码58
End Sub59

60
属性定义139

140
'''<summary>141
'''列表框复位142
'''</summary>143
Public Sub ItemClear()144
list.Items.Clear()145
list.DataSource = Nothing146
list.DataTextField = ""147
list.DataValueField = ""148
lbl_index.Text = "0"149
lbl_currpage.Text = "1"150
End Sub151

152
'''ItemCommand事件激活153
Private Sub list_ItemCommand(ByVal sender As Object, ByVal e As System.Web.UI.MobileControls.ListCommandEventArgs) Handles list.ItemCommand154
lbl_index.Text = e.ListItem.Index.ToString()155
'If Not (BestListItemCommand Is Nothing) Then156
RaiseEvent BestListItemCommand(sender, e)157
'End If158
End Sub159

160
'''<summary>161
''' 数据绑定162
''' </summary>163
Public Sub DataBindList()164
If Not (MyDataSoune Is Nothing) Then165
'得出当前记录总数166
Dim RoteCount As Integer = MyDataSoune.Rows.Count167
'当不同数据源绑定时恢复当前页为1(根据记录数判断是否是同一个数据源)168
Dim OldRoteCount As Integer = Convert.ToInt32(lbl_RoteCount.Text.Trim())169
If OldRoteCount <> 0 And OldRoteCount <> RoteCount Then170
lbl_currpage.Text = "1"171
End If172
lbl_RoteCount.Text = RoteCount.ToString()173
'得出页总数Dim tespint As Integer = RoteCount Mod PageSize
If tespint > 0 Then
'lbl_count.Text = Convert.ToString(CInt(RoteCount / PageSize) + 1)
lbl_count.Text = Convert.ToString(CInt((RoteCount - tespint) / PageSize) + 1)
176
Else177
lbl_count.Text = Convert.ToString(RoteCount / PageSize)178
End If179
If Convert.ToInt32(lbl_currpage.Text.Trim()) > 0 And Convert.ToInt32(lbl_currpage.Text.Trim()) <= Convert.ToInt32(lbl_count.Text.Trim()) Then180
'据当前页求出本页的开始记录和结束记录索引181
Dim start As Integer, tempend As Integer182
start = (Convert.ToInt32(lbl_currpage.Text.Trim()) - 1) * PageSize183
If Convert.ToInt32(lbl_currpage.Text.Trim()) = Convert.ToInt32(lbl_count.Text.Trim()) Then184
tempend = RoteCount - 1185
Else186
tempend = start + PageSize - 1187
End If188
list.Items.Clear()189
For i As Integer = start To tempend190
'初始化列表框191
Dim MyList As New MobileListItem192
MyList.Value = MyDataSoune.Rows(i)(list.DataValueField.Trim()).ToString()193
MyList.Text = MyDataSoune.Rows(i)(list.DataTextField.Trim()).ToString()194
list.Items.Add(MyList)195
Next196

197
End If198
'---------导航按钮控制199
If Convert.ToInt32(lbl_count.Text.Trim()) <= 1 Then200
'当只有一页时或没有记录时201
btn_first.Visible = False202
btn_syy.Visible = False203
btn_xyy.Visible = False204
btn_end.Visible = False205
Panel1.Visible = False206
ElseIf Convert.ToInt32(lbl_currpage.Text.Trim()) = 1 Then207
'当为第一页时208
btn_first.Visible = False209
btn_syy.Visible = False210
btn_xyy.Visible = True211
btn_end.Visible = True212
Panel1.Visible = True213
ElseIf Convert.ToInt32(lbl_currpage.Text.Trim()) = Convert.ToInt32(lbl_count.Text.Trim()) Then214
'当为最后一页时215
btn_first.Visible = True216
btn_syy.Visible = True217
btn_xyy.Visible = False218
btn_end.Visible = False219
Panel1.Visible = True220
ElseIf Convert.ToInt32(lbl_currpage.Text.Trim()) = 2 Then221
'当为第二页时222
btn_first.Visible = True223
btn_syy.Visible = False224
btn_xyy.Visible = True225
btn_end.Visible = True226
Panel1.Visible = True227
ElseIf Convert.ToInt32(lbl_currpage.Text.Trim()) = Convert.ToInt32(lbl_count.Text.Trim()) - 1 Then228
'当为最后一页时229
btn_first.Visible = True230
btn_syy.Visible = True231
btn_xyy.Visible = False232
btn_end.Visible = True233
Panel1.Visible = True234
Else235
btn_first.Visible = True236
btn_syy.Visible = True237
btn_xyy.Visible = True238
btn_end.Visible = True239
Panel1.Visible = True240
End If241
End If242
End Sub243

244
'''翻页处理245
Private Sub MyPageIdexChange(ByVal key As String)246
Select Case key247
Case "first"248
If Convert.ToInt32(lbl_count.Text.Trim()) > 0 Then249
lbl_currpage.Text = "1"250
End If251
Case "top"252
If Convert.ToInt32(lbl_currpage.Text.Trim()) > 1 Then253
lbl_currpage.Text = Convert.ToString(Convert.ToInt32(lbl_currpage.Text.Trim()) - 1)254
End If255
Case "next"256
If Convert.ToInt32(lbl_currpage.Text.Trim()) < Convert.ToInt32(lbl_count.Text.Trim()) Then257
lbl_currpage.Text = Convert.ToString(Convert.ToInt32(lbl_currpage.Text.Trim()) + 1)258
End If259
Case "last"260
If Convert.ToInt32(lbl_count.Text.Trim()) > 0 Then261
lbl_currpage.Text = lbl_count.Text.Trim()262
End If263
Case "go"264
If txt_go.Text.Trim() <> "" Then265
Dim igo As Integer = CInt(txt_go.Text.Trim())266
If igo <= Convert.ToInt32(lbl_count.Text.Trim()) And igo >= 1 Then267
lbl_currpage.Text = txt_go.Text.Trim()268
End If269
End If270
End Select271
'触发用户控件的PageIdexChange事件272
'If Not (BestListPageIndexChange Is Nothing) Then273
RaiseEvent BestListPageIndexChange(Me)274
'End If275
End Sub276

277

278
Private Sub btn_first_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_first.Click279
MyPageIdexChange("first")280
End Sub281

282
Private Sub btn_syy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_syy.Click283
MyPageIdexChange("top")284
End Sub285

286
Private Sub btn_xyy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_xyy.Click287
MyPageIdexChange("next")288
End Sub289

290
Private Sub btn_end_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_end.Click291
MyPageIdexChange("last")292
End Sub293

294
Private Sub btn_go_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_go.Click295
MyPageIdexChange("go")296
End Sub297
End Class298

引用页aspx代码
1
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="dzgw_dbgw.aspx.vb" Inherits="MoaWap.dzgw_dbgw" %>
2
<%@ Register TagPrefix="uc1" TagName="BestList" Src="../BestList.ascx" %>
3
<%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %>
4
<HEAD>
5
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
6
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
7
<meta content="http://schemas.microsoft.com/Mobile/Page" name="vs_targetSchema">
8
</HEAD>
9
<body Xmlns:mobile="http://schemas.microsoft.com/Mobile/WebForm">
10
<mobile:form id="FrmMain" title="待办公文" Paginate="True" runat="server">
11
<mobile:Panel id="Panel1" runat="server" BreakAfter="True">
12
<mobile:Link id="Link1" runat="server" BreakAfter="False" NavigateUrl="../main.aspx">主页</mobile:Link>
13
<mobile:Label id="Label2" runat="server" BreakAfter="False">></mobile:Label>
14
<mobile:Link id="Link2" runat="server" BreakAfter="False">电子公文</mobile:Link>
15
<mobile:Label id="Label1" runat="server" BreakAfter="False">>待办公文</mobile:Label>
16
</mobile:Panel>
17
<uc1:BestList id="blist_dzgw" runat="server"></uc1:BestList>
18
</mobile:form>
19
</body>
20
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="dzgw_dbgw.aspx.vb" Inherits="MoaWap.dzgw_dbgw" %>2
<%@ Register TagPrefix="uc1" TagName="BestList" Src="../BestList.ascx" %>3
<%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %>4
<HEAD>5
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">6
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">7
<meta content="http://schemas.microsoft.com/Mobile/Page" name="vs_targetSchema">8
</HEAD>9
<body Xmlns:mobile="http://schemas.microsoft.com/Mobile/WebForm">10
<mobile:form id="FrmMain" title="待办公文" Paginate="True" runat="server">11
<mobile:Panel id="Panel1" runat="server" BreakAfter="True">12
<mobile:Link id="Link1" runat="server" BreakAfter="False" NavigateUrl="../main.aspx">主页</mobile:Link>13
<mobile:Label id="Label2" runat="server" BreakAfter="False">></mobile:Label>14
<mobile:Link id="Link2" runat="server" BreakAfter="False">电子公文</mobile:Link>15
<mobile:Label id="Label1" runat="server" BreakAfter="False">>待办公文</mobile:Label>16
</mobile:Panel>17
<uc1:BestList id="blist_dzgw" runat="server"></uc1:BestList>18
</mobile:form>19
</body>20

引用页 VB代码
1
Public Class dzgw_dbgw
2
Inherits System.Web.UI.MobileControls.MobilePage
3
Protected WithEvents Label1 As System.Web.UI.MobileControls.Label
4
Protected WithEvents Link1 As System.Web.UI.MobileControls.Link
5
Protected WithEvents Panel1 As System.Web.UI.MobileControls.Panel
6
Protected WithEvents Link2 As System.Web.UI.MobileControls.Link
7
Protected WithEvents Label2 As System.Web.UI.MobileControls.Label
8
Protected WithEvents FrmMain As System.Web.UI.MobileControls.Form
9
'声明自定义控件
10
Private WithEvents blist_dbgw As BestList
11
12
Web 窗体设计器生成的代码
26
27
Private uid As String
28
''用于事件关联
29
'Private WithEvents blist As BestList
30
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
31
''-------页面访问权限控制--------
32
'If Not Config.ChkPage(Convert.ToString(Session("xtqx")), "0102000000") Then
33
' Me.RedirectToMobilePage("../index.aspx")
34
'End If
35
'获取用户控件
36
blist_dbgw = CType(Me.FindControl("blist_dzgw"), BestList)
37
38
End Sub
39
40
Private Sub blist_dbgw_ItemCommand(ByVal sender As Object, ByVal e As System.Web.UI.MobileControls.ListCommandEventArgs) Handles blist_dbgw.BestListItemCommand
41
If Not (e.ListItem Is Nothing) Then
42
'blist_dbgw.SelectIndex的使用
43
Response.Write(blist_dbgw.Items(blist_dbgw.SelectIndex).Text)
44
End If
45
End Sub
46
47
Private Sub blist_fgs_dbgweIndexChange(ByVal sender As Object) Handles blist_dbgw.BestListPageIndexChange
48
'重新绑定一下数据
49
filldata()
50
End Sub
51
52
Private Sub FrmMain_Activate(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FrmMain.Activate
53
filldata()
54
End Sub
55
56
Private Sub filldata()
57
Dim sqlstr As String = "select * from pt_login"
58
'初始化列表
59
blist_dbgw.DataTextField = "v_xm"
60
blist_dbgw.DataValueField = "v_dlid"
61
blist_dbgw.PageSize = 1
62
blist_dbgw.DataSoune = class_data.foundcnx(sqlstr, "t_dbsw").Tables(0)
63
blist_dbgw.DataBindList()
64
End Sub
65
End Class
66
效果
Public Class dzgw_dbgw2
Inherits System.Web.UI.MobileControls.MobilePage3
Protected WithEvents Label1 As System.Web.UI.MobileControls.Label4
Protected WithEvents Link1 As System.Web.UI.MobileControls.Link5
Protected WithEvents Panel1 As System.Web.UI.MobileControls.Panel6
Protected WithEvents Link2 As System.Web.UI.MobileControls.Link7
Protected WithEvents Label2 As System.Web.UI.MobileControls.Label8
Protected WithEvents FrmMain As System.Web.UI.MobileControls.Form9
'声明自定义控件10
Private WithEvents blist_dbgw As BestList11

12
Web 窗体设计器生成的代码26

27
Private uid As String28
''用于事件关联29
'Private WithEvents blist As BestList30
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load31
''-------页面访问权限控制--------32
'If Not Config.ChkPage(Convert.ToString(Session("xtqx")), "0102000000") Then33
' Me.RedirectToMobilePage("../index.aspx")34
'End If35
'获取用户控件36
blist_dbgw = CType(Me.FindControl("blist_dzgw"), BestList)37

38
End Sub39

40
Private Sub blist_dbgw_ItemCommand(ByVal sender As Object, ByVal e As System.Web.UI.MobileControls.ListCommandEventArgs) Handles blist_dbgw.BestListItemCommand41
If Not (e.ListItem Is Nothing) Then42
'blist_dbgw.SelectIndex的使用43
Response.Write(blist_dbgw.Items(blist_dbgw.SelectIndex).Text)44
End If45
End Sub46

47
Private Sub blist_fgs_dbgweIndexChange(ByVal sender As Object) Handles blist_dbgw.BestListPageIndexChange48
'重新绑定一下数据49
filldata()50
End Sub51

52
Private Sub FrmMain_Activate(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FrmMain.Activate53
filldata()54
End Sub55

56
Private Sub filldata()57
Dim sqlstr As String = "select * from pt_login"58
'初始化列表59
blist_dbgw.DataTextField = "v_xm"60
blist_dbgw.DataValueField = "v_dlid"61
blist_dbgw.PageSize = 162
blist_dbgw.DataSoune = class_data.foundcnx(sqlstr, "t_dbsw").Tables(0)63
blist_dbgw.DataBindList()64
End Sub65
End Class66


浙公网安备 33010602011771号