开发者

Custom Paging in Child (Inner) Nested Repeaters

I am using nested repeaters with Dataset (not using Datatable) to retrieve information by passing parameters. So far I have bind the two repeaters clearly and everything is working fine.

Here the list of messages created by each user datawise(parameter passed) will be displayed, and there could be more than 50 messages created by each user daily. So now I want to do custom paging for each user.

But I am unable to proceed further, as the next, previous, back, first links are placed inside the child repeaters footer template and I couldn't access these links even by findcontrol method.

Example:

User1

No Msg Code

1 abcd Cl-6

2 some Cl-4

3 swedf Cl-3

4 sddf Cl-1

1,2,3,4,5 (Paging)

User2

No Msg Code

1 dgfv Cl-96

2 abcd Cl-4

3 sjuc Cl-31

4 liot Cl-1

1,2,3,4,5 (Paging)

In this ways goes for every user:

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

XML:

<asp:Repeater  id="Rep1" runat="server" OnItemCommand="Rep1_ItemCommand" EnableViewState = "false"  >

    <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%>

 <%--   OnItemDataBound="Rep2_ItemDataBound" --%>

    <asp:Repeater id="Rep2" runat="server"  datasource='<%#(Container.DataItem).Row.GetChildRows("CrdRelation") %>' >
    <HeaderTemplate>
    <table border="1" width="100%" >
    &l开发者_StackOverflow社区t;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>
<br />
   </table>
    </FooterTemplate>
    </asp:Repeater>

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

    </asp:Repeater>  

I couldn't understand how to do paging.


You shroud read about it:

  • http://idunno.org/archive/2004/10/30/145.aspx
  • http://support.microsoft.com/kb/306154
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜