子(内)嵌套中继器中的自定义分页

时间:2010-07-12 12:54:03

标签: asp.net vb.net

Iam使用带有数据集的嵌套转发器(不使用Datatable)通过传递参数来检索信息。

到目前为止,我已经清楚地绑定了两个中继器,一切正常
这里将显示每个用户datawise(参数传递)创建的消息列表,每个用户每天可以创建超过50条消息,所以现在我想为每个用户进行自定义分页。 />

但Iam无法继续前进,因为下一个,上一个,后一个,第一个链接被放置在子转发器页脚模板内,即使通过findcontrol方法我也无法访问这些链接。

PLZ任何人帮助我。
太紧急了。
我在最近3天敲打了我的头。

用户1
没有消息代码
   1 abcd Cl-6
   2一些Cl-4
   3 swedf Cl-3
   4 sddf Cl-1
            
            1,2,3,4,5(寻呼)

User2
没有消息代码
   1 dgfv Cl-96
   2 abcd Cl-4
   3 sjuc Cl-31
   4 liot Cl-1
            
            1,2,3,4,5(寻呼)
-------------
-----------
----------

以这种方式适用于每个用户

Public Sub CreateNestedRepeater()

        Dim strSql_1 As String, strsql_2 As String
        Dim strCon_1 As New SqlConnection
        Dim strCon_2 As New SqlConnection
        Dim ds As New DataSet()
        frmDate = AMS.convertmmddyy(txtFromDate.Text)
        toDate = AMS.convertmmddyy(txtToDate.Text)
        strCon_1 = New SqlConnection(ConfigurationManager.ConnectionStrings("connectionString").ConnectionString)
            strSql_1 = "select User_Login, User_Id from V_mst_UserMaster Where User_Flag = 1 and User_Type='CO'"
            Dim daCust As New SqlDataAdapter(strSql_1, strCon_1)
            daCust.Fill(ds, "RptCoord_Name")

            WhereClause1 = "where MsgHdr_Id NOT IN (Select a.MsgHdr_Id from V_AMS_GetSentMsg as a Join V_AMS_GetSentMsg as b " _
          & "on a.MsgHdr_Id = b.MsgHdr_PrevMsgId) and MsgHdr_Date >= '" & frmDate & "' and MsgHdr_Date <= '" & toDate & _
          "'AND MsgHdr_MsgFlag='I' and MsgHdr_AckReq <> 'N'"

            OrderBy = "order by MsgHdr_Date asc"

            strCon_2 = New SqlConnection(ConfigurationManager.ConnectionStrings("conn_Ind_AKK_TRAN").ConnectionString)
            strsql_2 = "select User_Login,MsgHdr_Date, Client_Code, MsgHdr_RefNo, MsgType_Name, MsgHdr_Subject " _
                    & " from V_AMS_GetSentMsg " & WhereClause1 & OrderBy
            Dim daOrders As New SqlDataAdapter(strsql_2, strCon_2)
            daOrders.Fill(ds, "RptCd_Record")

            Dim rel As New DataRelation("CrdRelation", ds.Tables("RptCoord_Name").Columns("User_Login"), ds.Tables("RptCd_Record").Columns("User_Login"), False)
            ds.Relations.Add(rel)
            rel.Nested = True
            Rep1.DataSource = ds.Tables("RptCoord_Name").DefaultView
            Rep1.DataBind()
            strCon_1.Close()
            strCon_2.Close()
       End Sub

    Protected Sub Rep1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles Rep1.ItemCommand
        If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
            DirectCast(e.Item.FindControl("Rep2"), Repeater).DataSource = DirectCast(e.Item.DataItem, DataRowView).CreateChildView("CrdRelation")
            DirectCast(e.Item.FindControl("Rep2"), Repeater).DataBind()
        End If

     End Sub

    Protected Sub Pagging(ByVal index As Integer)
        Dim PDS As New PagedDataSource
        PDS.DataSource = ds.Tables("RptCoord_Name").DefaultView
        PDS.CurrentPageIndex = index
        PDS.AllowPaging = True
        PDS.PageSize = 4

        Dim rep2 As Repeater = CType(e
        rep2.DataSource = PDS
        Rep2.DataBind()
        Dim ddl As DropDownList = DirectCast(rep2.Controls(rep2.Controls.Count - 1).FindControl("PageCount"), DropDownList)
        If ddl IsNot Nothing Then
            For i As Integer = 1 To PDS.PageCount - 1
                ddl.Items.Add(i.ToString())
            Next
        End If
    End Sub

    Public Sub PageIndex(ByVal sender As Object, ByVal e As EventArgs)
        Dim ddl As DropDownList = DirectCast(rep2.Controls(rep2.Controls.Count - 1).FindControl("PageCount"), DropDownList)
        Pagging(Integer.Parse(ddl.SelectedItem.Text) - 1)
    End Sub


<ItemTemplate>   
<table width="100%" border="0.8" cellpadding="0" cellspacing="0" CssClass="bodytext" >
<tr><td  align="center" class="RepHeader" > 
    Incoming Messages - Pending Ack for 
<%#getUser(DataBinder.Eval(Container.DataItem, "User_Login"))%> from <%= txtFromDate.Text %> 
    to <%=txtToDate.Text%>
 
<asp:Repeater id="Rep2" runat="server"  datasource='<%#(Container.DataItem).Row.GetChildRows("CrdRelation") %>' >
<HeaderTemplate>
<table border="1" width="100%" >
<tr class="RepHeader" >    
<td>Msg Date</td><td>CL Code</td><td>INCRefNo</td><td>Contents</td><td>Subject</td></tr></HeaderTemplate><ItemTemplate>
<tr class="RrpList">
        <td><%#getdate(CType(Container.DataItem, System.Data.DataRow)("MsgHdr_Date"))%> </td>
        <td><%#CType(Container.DataItem, System.Data.DataRow)("Client_Code")%> </td>            
        <td><asp:LinkButton ID="lnkRef" runat="server"></asp:LinkButton> 
            <a id="hrefRefNo" runat="server" href="#" class="Link" >
            <%#CType(Container.DataItem, System.Data.DataRow)("MsgHdr_RefNo")%></a></td>
        <td><%#CType(Container.DataItem, System.Data.DataRow)("MsgType_Name")%> </td>
        <td><%#CType(Container.DataItem, System.Data.DataRow)("MsgHdr_Subject")%> </td>
</tr>

</ItemTemplate>       
<FooterTemplate>


  <%--Starts Here - (Paging for Pending Nested Repeaters) --%>

<tr align="center" class = "RepHeader">        
<td colspan="5">            

<asp:LinkButton ID="lnkFirst" runat="server" ForeColor="Black" Text="First"  >
</asp:LinkButton>&nbsp;

<asp:LinkButton ID="lnkPrevious" runat="server" ForeColor="Black" Text="Previous" >
</asp:LinkButton>&nbsp;&nbsp;&nbsp;Now Showing Page&nbsp;    

 <asp:DropDownList ID="ddlpageNumbers" runat="server" AutoPostBack="true" >  
 </asp:DropDownList>&nbsp;of&nbsp; <asp:Label ID="lblTotalPages" runat="server"> </asp:Label>
    &nbsp;Pages.&nbsp;           

 <asp:LinkButton ID="lnkNext" runat="server" ForeColor="Black" Text="Next" >  
 </asp:LinkButton>&nbsp;            
 <asp:LinkButton ID="lnkLast" runat="server" ForeColor="Black" Text="Last" > 
 </asp:LinkButton>        
 </td>    </tr>

 <%--Ends Here (Paging for Pending Nested Repeaters)--%>
</td></tr>


             

</ItemTemplate>
<SeparatorTemplate><br /><br /></SeparatorTemplate>

</asp:Repeater>  

我不明白如何进行分页

请帮助我 谢谢 Brightsy

1 个答案:

答案 0 :(得分:0)