想学学 repeater控件,和它如何翻页适合像我这样入门级用户的文章,多谢
解决方案 »
- .net,javascript常用的开发框架有那些
- asp.net 关于母板页问题,高手进,如果方法好,可以继续加分!
- 时间可以这样用吗asp.net+vb.net+sqlserver
- ***求一个例子,解决马上结帖 (谢谢!)***
- 关于用户自定义控件的一些问题....请各位大哥指教指教
- 怎么样将最新的数据库信息及时得写入指定的xml文件?
- 各位兄弟帮忙,给我介绍几个公司
- 将DataGrid中的数据导出为excel文件时字段名显示的为乱码
- 在datagrid控件上点删除,弹出一个确认和取消的消息框,该怎么写,能不能给个现成的代码看看?
- 通过 2 个输入框 动态调整大小 ,但是不起作用 ?不是 后端 设置属性 会覆盖前端的吗 ?
- 点击选择下拉列表框的某一项会激发什么事件?
- 高分求救2个问题
<table cellSpacing="0" borderColorDark="#ffffff" cellPadding="1" width="100%" align="left"
bgColor="#ffffff" borderColorLight="#3677b1" border="1">
<asp:repeater id="rpt_Graduate" runat="server">
<headertemplate>
<tr bgcolor="#ffdcb5">
<th height="26" width="36">
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
<tr>
<td>
<div align="center"></div>
</td>
</tr>
</table>
</th>
<th height="26" width="300">
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
<tr>
<td>
<div align="center"><font color="#FFFFFF">工具类别</font></div>
</td>
</tr>
</table>
</th>
<th height="26" width="204">
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
<tr>
<td>
<div align="center"><font color="#FFFFFF">类别编码</font></div>
</td>
</tr>
</table>
</th>
<th height="26" width="67">
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
<tr>
<td>
<div align="center"><font color="#FFFFFF">上移</font></div>
</td>
</tr>
</table>
</th>
<th height="26" width="59">
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
<tr>
<td>
<div align="center"><font color="#FFFFFF">下移</font></div>
</td>
</tr>
</table>
</th>
<th height="26" width="61">
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
<tr>
<td>
<div align="center"><font color="#FFFFFF" class="table_head_font">修改</font></div>
</td>
</tr>
</table>
</th>
</tr>
</headertemplate>
<itemtemplate>
<tr>
<td height="24" width="36" align="center">
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
<tr>
<td>
<div align="center">
<%# Container.ItemIndex+1%>
<asp:Label ID="lbl_Order_Id" Visible=False Text='<%# DataBinder.Eval(Container.DataItem,"order_id").ToString() %>' Runat=server/>
</div>
</td>
</tr>
</table>
</td>
<td height="24" width="300" align="center">
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
<tr>
<td class="font_dropshadow">
<div align="center">
<%# DataBinder.Eval(Container.DataItem,"mytext").ToString() %>
</div>
</td>
</tr>
</table>
</td>
<td height="24" width="204" align="center">
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
<tr>
<td class="font_dropshadow">
<div align="center">
<%# DataBinder.Eval(Container.DataItem,"myvalue").ToString() %>
</div>
</td>
</tr>
</table>
</td>
<td height="24" align="center" width="67">
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
<tr>
<td class="font_dropshadow">
<div align="center">
<asp:HyperLink id="myupHyperlink" runat="server" NavigateUrl='<%# "Jc_GZTreeRightmove.aspx?operate=top&nodeid=" & DataBinder.Eval(Container.DataItem,"nodeid").ToString() %>'>上移</asp:HyperLink>
</div>
</td>
</tr>
</table>
</td>
<td height="24" align="center" width="59">
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
<tr>
<td class="font_dropshadow">
<div align="center">
<asp:HyperLink NavigateUrl='<%# "Jc_GZTreeRightmove.aspx?operate=down&nodeid=" & DataBinder.Eval(Container.DataItem,"nodeid").ToString() %>' runat="server" ID="mydownHyperlink">下移</asp:HyperLink>
</div>
</td>
</tr>
</table>
</td>
<td height="24" width="61">
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
<tr>
<td class="font_dropshadow">
<div align="center">
<asp:HyperLink id="myeidtHyperlink" runat="server" NavigateUrl='<%# "Jc_GZTreeRightedit.aspx?nodeid=" + DataBinder.Eval(Container.DataItem,"nodeid").ToString() %>'>修改</asp:HyperLink>
</div>
</td>
</tr>
</table>
</td>
</tr>
</itemtemplate>
</asp:repeater>
<tr>
<td align="right" colSpan="6">共
<asp:label id="RecordCount" Runat="server"></asp:label>条记录┊<asp:linkbutton id="Linkfirst" Runat="server">首页</asp:linkbutton>┊<asp:linkbutton id="Linkpre" Runat="server">上一页</asp:linkbutton>┊<asp:linkbutton id="Linknext" Runat="server">下一页</asp:linkbutton>┊<asp:linkbutton id="Linklast" Runat="server">尾页</asp:linkbutton>┊第<asp:label id="No" Runat="server"></asp:label>/<asp:label id="Ltoalcount" Runat="server"></asp:label>
</FONT>页┊<asp:label id="numofpage" Runat="server"></asp:label>条记录/页┊转到第
<asp:dropdownlist id="toalcount" tabIndex="6" Runat="server" AutoPostBack="True"></asp:dropdownlist>页
</td>
</tr>
</table>
'注意:此处的pageNumber,是我们所说的序列从0开始!
Dim ds As New DataSet
Dim myadapter As New OdbcDataAdapter(sql, myCon)
myadapter.Fill(ds)
'此段代码来自付平,具体含义从字面可以理解
Dim pager As New PagedDataSource
pager.AllowPaging = True
pager.PageSize = 10
pager.DataSource = ds.Tables(0).DefaultView
RecordCount.Text = pager.DataSourceCount
Ltoalcount.Text = pager.PageCount
numofpage.Text = pager.PageSize pager.CurrentPageIndex = pageNumber
No.Text = pageNumber + 1
labCurPage.Text = pageNumber If Ltoalcount.Text = 1 Then 'only 1 page
Linklast.Enabled = False
Linknext.Enabled = False
Linkpre.Enabled = False
Linkfirst.Enabled = False
End If
If Ltoalcount.Text > 1 Then ' more pages>1
If pageNumber = 0 Then 'the cur is the first page
Linklast.Enabled = True
Linknext.Enabled = True
Linkpre.Enabled = False
Linkfirst.Enabled = False
End If
If pageNumber = Ltoalcount.Text - 1 Then 'the cur is the last page
Linklast.Enabled = False
Linknext.Enabled = False
Linkpre.Enabled = True
Linkfirst.Enabled = True
End If
If 0 < pageNumber And pageNumber < Ltoalcount.Text - 1 Then 'the cur is in the first and last
Linklast.Enabled = True
Linknext.Enabled = True
Linkpre.Enabled = True
Linkfirst.Enabled = True
End If
If pageNumber > pager.PageCount - 1 Then
Exit Sub
End If
End If Dim i As Integer
If toalcount.Items.Count > 0 Then
toalcount.Items.Clear()
End If
For i = 0 To pager.PageCount - 1
toalcount.Items.Add(i + 1)
Next myrepeater.DataSource = pager
myrepeater.DataBind()
toalcount.Items(pageNumber).Selected = True
End Sub
Private Sub toalcount_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles toalcount.SelectedIndexChanged
BindRepeater(labSel.Text, rpt_Graduate, toalcount.SelectedIndex)
End Sub
Private Sub Linkpre_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Linkpre.Click
Dim i As Integer = labCurPage.Text - 1
BindRepeater(labSel.Text, rpt_Graduate, i)
End Sub
Private Sub Linknext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Linknext.Click
Dim i As Integer = labCurPage.Text + 1
BindRepeater(labSel.Text, rpt_Graduate, i)
End Sub
Private Sub Linkfirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Linkfirst.Click
BindRepeater(labSel.Text, rpt_Graduate, 0)
End Sub
Private Sub Linklast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Linklast.Click
Dim i As Integer = Ltoalcount.Text - 1
BindRepeater(labSel.Text, rpt_Graduate, i)
End Sub