梦醒三分,执着疯子
没有什么不可以!

一、DataGrid模板列一般格式:
<asp:TemplateColumn HeaderText="模板列名">
       <ItemTemplate>
        <asp:LinkButton ID="SelectBtn" Text='<%# DataBinder.Eval(Container,"DataItem.ExpeAlias")%>' CommandName="Update" runat="server" />
       </ItemTemplate>
      </asp:TemplateColumn>

二、DataGrid分页:
PageSize="15"  //每页最大行数
AllowPaging="True"  //是否允许分页
PagerStyle-Mode="NumericPages"  //分页格式

//DataGrid以外的分页按钮
<asp:linkbutton id="btnFirst" style="Z-INDEX: 100; LEFT: 264px; POSITION: absolute; TOP: 64px" onclick="PagerButtonClick"
     runat="server" Font-size="11pt" text="首 页" Font-Name="verdana" CommandArgument="1" ></asp:linkbutton>
    <asp:linkbutton id="btnPrev" style="Z-INDEX: 101; LEFT: 336px; POSITION: absolute; TOP: 64px" onclick="PagerButtonClick"
     runat="server" Font-size="11pt" text="上一页" Font-Name="verdana" CommandArgument="prev" ></asp:linkbutton>
    <asp:linkbutton id="btnNext" style="Z-INDEX: 102; LEFT: 400px; POSITION: absolute; TOP: 64px" onclick="PagerButtonClick"
     runat="server" Font-size="11pt" text="下一页" Font-Name="verdana" CommandArgument="next" ></asp:linkbutton>
    <asp:linkbutton id="btnLast" style="Z-INDEX: 103; LEFT: 464px; POSITION: absolute; TOP: 64px" onclick="PagerButtonClick"
     runat="server" Font-size="11pt" text="下一页" Font-Name="verdana" CommandArgument="last" ></asp:linkbutton>

在代码中加入以下代码(VB.Net):
Sub PagerButtonClick(ByVal sender As Object, ByVal e As EventArgs)

        Dim arg As String = CType(sender, LinkButton).CommandArgument
        Select Case arg
            Case "next"
                If expeDg.CurrentPageIndex < expeDg.PageCount - 1 Then
                    expeDg.CurrentPageIndex += 1
                End If
            Case "prev"
                If expeDg.CurrentPageIndex > 0 Then
                    expeDg.CurrentPageIndex -= 1
                End If
            Case "last"
                expeDg.CurrentPageIndex = (expeDg.PageCount - 1)
            Case Else
                expeDg.CurrentPageIndex = 0
        End Select
        ExpeBind() //绑定列表
    End Sub

posted on 2006-10-07 16:42  Jacker.W  阅读(242)  评论(0编辑  收藏  举报