Find a repeater that is within another repeater - asp.net

Ok so my issue is I have three repeaters. Within that repeater I have another repeater and a third one in the second. There is more in between but that's not relevant. Below the HTML is my VB code. My issue is that rptCrashPercentageAvg reutrns Nothing. How can rptCrashStatsDisplay access rptCrashPercentageAvg?
<asp:Repeater ID="rptCrashStatsDisplay" runat="server">
<ItemTemplate>
<asp:Repeater ID="rptCrashPercentage" runat="server">
<ItemTemplate>
<tr class="statsRowA">
<td class="emphasis" style="padding-left: 20px">
<%# DataBinder.Eval(Container.DataItem,"CRASH_TYPE_DESC") %>:
</td>
<td style="padding-left: 5px">
<%--background-color: <%# Iif(DataBinder.Eval(Container.DataItem,"CRASH_TYPE_PERCENT")>DataBinder.Eval(Container.DataItem,"COUNT(*)"), "red", "null") %>"--%>
<%#String.Format("{0:N1}", DataBinder.Eval(Container.DataItem, "CRASH_TYPE_PERCENT"))%>
%
</td>
<asp:Repeater ID="rptCrashPercentageAvg" runat="server">
<ItemTemplate>
<td style="padding-left: 5px">
<%#String.Format("{0:N1}", DataBinder.Eval(Container.DataItem, "AVG_VAL"))%>
%
</td>
</ItemTemplate>
</asp:Repeater>
</tr>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
Private Sub rptCrashStatsDisplay_ItemDataBound(ByVal sender As System.Object, _
ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptCrashStatsDisplay.ItemDataBound
Dim dv As DataRowView = CType(e.Item.DataItem, DataRowView)
If Not IsNothing(dv) Then
Dim rptCrashPercentage As Repeater = CType(e.Item.FindControl("rptCrashPercentage"), Repeater)
Dim view As DataView = dv.CreateChildView("statRel1")
If (view.Count > 0) Then
rptCrashPercentage.DataSource = view
rptCrashPercentage.DataBind()
End If
Dim rptCrashPercentageAvg As Repeater = CType(e.Item.FindControl("rptCrashPercentageAvg"), Repeater)
Dim viewAvg As DataView = dv.CreateChildView("statRel2")
If (viewAvg.Count > 0) Then
rptCrashPercentageAvg.DataSource = viewAvg
rptCrashPercentageAvg.DataBind()
End If
End If
End Sub

I would try making sure you're looking for it in the correct place. It'll look in your repeater's Header for the control and since it won't find it there, it'll be Nothing the first time you try and use it.
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
Dim rptCrashPercentageAvg As Repeater = CType(e.Item.FindControl("rptCrashPercentageAvg"), Repeater)
'Shouldn't be "nothing" here.
End If
Otherwise you could try a more inefficient method:
Dim rptCrashPercentageAvg As Repeater = CType(e.Item.FindControl("rptCrashPercentageAvg"), Repeater)
If rptCrashPercentageAvg IsNot Nothing Then
Dim viewAvg As DataView = dv.CreateChildView("statRel2")
If (viewAvg.Count > 0) Then
rptCrashPercentageAvg.DataSource = viewAvg
rptCrashPercentageAvg.DataBind()
End If
End If
Edit: Also, since it actually is a repeater, you shouldn't need the CType.

Related

total in repeater footer, itemdatabound in VB.NET

I want to sum the total of the gender at the repeater footer using vb.net by using item data bound, the behind code is wrong cause I don't know how to do it...
FRONT CODE
<asp:Repeater ID="repGender" runat="server">
<HeaderTemplate>
<table cellspacing="0" rules="all" border="1">
<tr>
<th>Gender</th>
<th>Total</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<%# Eval("GENDER")%>
</td>
<td style="text-align: center">
<%# Eval("TOTAL")%></a>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr style="font-weight: bold">
<td>Grand Total</td>
<td style="text-align: center">
<asp:Label runat="server" ID="lblTotal"></asp:Label>
</td>
</tr>
</table>
</FooterTemplate>
</asp:Repeater>
BEHIND CODE
Protected Sub repGender_ItemDataBound(sender As Object, e As RepeaterItemEventArgs) Handles repGender.ItemDataBound
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
Total += Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, ""))
Else e.Item.ItemType == ListItemType.Footer
End If
End Sub
Ok, so we need to define a simple total var at the form's "class" level. it only needs to persist during the data bind operation.
So, given your above markup, then we have this code to load the repeater.
Dim MyTotal As Integer
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
LoadData
End If
End Sub
Sub LoadData()
Dim strSQL As String =
"SELECT Gender, count(*) as TOTAL
FROM Employee
GROUP BY Gender"
Dim rstData As New DataTable
Using mycon As New SqlConnection(GetConstr)
Using cmdSQL As New SqlCommand(strSQL, mycon)
mycon.Open()
rstData.Load(cmdSQL.ExecuteReader)
End Using
End Using
MyTotal = 0
repGender.DataSource = rstData
repGender.DataBind()
End Sub
And with your markup we see/get this:
And our data row bind event looks like this:
Protected Sub repGender_ItemDataBound(sender As Object, e As RepeaterItemEventArgs) Handles repGender.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or
e.Item.ItemType = ListItemType.AlternatingItem Then
' We don't have lable or text box with an "id" in repeat
' section, (can't use find control unless you assign "id" to these controls).
' so, lets grab the whole data row used for binding
Dim gData As DataRowView = e.Item.DataItem
MyTotal = MyTotal + gData.Item("TOTAL")
End If
If e.Item.ItemType = ListItemType.Footer Then
' set the total value in footer
Dim lblTotal As Label = e.Item.FindControl("lblTotal")
lblTotal.Text = MyTotal
End If
End Sub

how to make a label in a nested repeater visible programmatically

I have two repeaters, one nested in the other. I'm outputting a list of course titles in the parent repeater and the dates of those courses in the child repeater. This part is working fine. But, not all the course titles necessarily have dates available at any given time, so I want to be able to put a message up under each Course title that currently has no dates saying to check back regularly, blah, blah, blah. I've put the label in the footer template of the nested repeater with visibility=false and am trying to set the visibility=true at the appropriate time in the ItemDataBound Sub. Unfortunately, this is not working. I'm not getting any errors, the label just isn't showing up. I'm really hoping someone can help me out with my code or suggest an alternate way to do this. I'm kinda new to asp.net(VB) and am still struggling a bit. I've never tried nesting repeaters before. Here is my code:
.aspx
<asp:Repeater ID="rptTech" runat="server" >
<HeaderTemplate>
<table class="tableCourses">
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<strong><asp:Label runat="server" ID="lblCourseName" Text='<%# Eval("CourseName") %>'></asp:Label></strong>
<br />
<asp:Label runat="server" ID="lblCourseSummary" Text='<%# Eval("Summary") %>'></asp:Label>
<br />
<asp:HyperLink ID="hpCourseMaterial" Visible='<%# CheckCourseMaterial(Eval("CourseMaterial")) %>' NavigateUrl='<%# "/files/Portal_Course_Material/" & Eval("CourseMaterial")%>' Text="Download Course Material" runat="server"></asp:HyperLink>
</td>
</tr>
<tr>
<td>
<asp:Repeater ID="rptTechDates" DataSource='<%#Eval("relCourses") %>' runat="server" >
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<strong><asp:Label runat="server" ID="lblDate" Text='<%# CDate(Eval("dteDate")).ToString("dd/MM/yyyy") %>'></asp:Label></strong><br />
<asp:Label runat="server" ID="dteTime" Text='<%# "Time: " & CDate(Eval("dteTime2")).ToString("HH:mm") & " EST" %>'></asp:Label><br />
<asp:HyperLink ID="Register" NavigateUrl='<%# "/Test.aspx?intMeetingID2=" & Eval("pkWebinarID")%>' Text="Register" runat="server"></asp:HyperLink>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td>
<asp:Label ID="lblNoCourses" Text="There are no course dates available at this time. Please check back regularly to see any updates." runat="server" Visible="False"></asp:Label>
</td>
</tr>
</table>
</FooterTemplate>
</asp:Repeater>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
And Codebehind:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim curDate As Date = CDate(Now)
'Create the connection
Dim connstring As String
connstring = ConfigurationManager.ConnectionStrings("LPISQLConn").ConnectionString
Using conn As New SqlConnection(connstring)
Dim cmd As New SqlCommand("SELECT foo1, foo2, foo3 FROM tblFoo", conn)
cmd.CommandType = CommandType.Text
Dim ad As New SqlDataAdapter(cmd)
Dim ds As New DataSet()
ad.Fill(ds)
ds.Relations.Add(New DataRelation("relCourses", ds.Tables(0).Columns("fkcrsID"), ds.Tables(1).Columns("webinarID"), False))
rptTech.DataSource = ds.Tables(0)
rptTech.DataBind()
End Using
End Sub
Protected Sub rptTech_ItemDataBound(ByVal sender As Object, ByVal e As RepeaterItemEventArgs)
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
Dim drv As DataRowView = TryCast(e.Item.DataItem, DataRowView)
Dim rptTechDates As Repeater = TryCast(e.Item.FindControl("rptTechDates"), Repeater)
rptTechDates.DataSource = drv.CreateChildView("relCourses")
If rptTechDates.Items.Count < 1 And rptTechDates IsNot Nothing Then
If e.Item.ItemType = ListItemType.Footer Then
Dim lblNoCourses As Label = TryCast(e.Item.FindControl("lblNoCourses"), Label)
If lblNoCourses IsNot Nothing Then
lblNoCourses.Visible = True
End If
End If
Else
rptTechDates.DataBind()
End If
End If
End Sub
I would do the following:
Change your ItemDataBoundEvent for the parent repeater to:
Protected Sub rptTech_ItemDataBound(ByVal sender As Object, ByVal e As RepeaterItemEventArgs)
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
Dim drv As DataRowView = TryCast(e.Item.DataItem, DataRowView)
Dim rptTechDates As Repeater = TryCast(e.Item.FindControl("rptTechDates"), Repeater)
rptTechDates.DataSource = drv.CreateChildView("relCourses")
rptTechDates.DataBind()
End If
End Sub
Add this to the markup of your child repeater:
OnItemDataBound="rptTechDates_ItemDataBound"
Now add this:
Protected Sub rptTechDates_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs)
If e.Item.ItemType = ListItemType.Footer Then
If DirectCast(DirectCast(e.Item.NamingContainer, Repeater).DataSource, DataTable).Rows.Count = 0 Then
DirectCast(e.Item.FindControl("lblNoCourses"), Label).Visible = True
End If
End If
So, if the number of rows in the child repeater's datasource is 0, then show the label.
EDIT After comment from OP
Protected Sub rptTechDates_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs)
If e.Item.ItemType = ListItemType.Footer Then
If DirectCast(DirectCast(e.Item.NamingContainer, Repeater).DataSource, DataView).Count = 0 Then
DirectCast(e.Item.FindControl("lblNoCourses"), Label).Visible = True
End If
End If
You want to search rptTechDates repeater for the lblNoCourses control. The e.Item.FindControl("lblNoCourses") is searching the rptTech repeater which doesn't exist. See this question to search the control in the rptTechDates footer.
Also, you'll want to call Databind() on the repeater after setting it's DataSource
rptTechDates.DataSource = drv.CreateChildView("relCourses")
rptTechDates.Databind()

ASP.net dropdownlist unexpected event firing behavior

I'm experiencing some odd behavior with drop down boxes and I'm hoping someone could explain what's going on. I have a datarepeater that builds out a table of rows. Each row has a dropdownlist (hidden) and a linkbutton (not hidden) in a cell. The expected behavior is that when a user clicks the linkbutton for a specific cell, it fires a server command. This command does a few things but also sets the selected value of the DDL and then sets it visible and sets itself (the linkbutton) hidden. The problem is that the dropdownlist's event should fire every time the selected index changes. But, what ends up happening is that it only fires the first time the user changes the DDL value. After that, the event will stop firing. Also, all of this is in a usercontrol and all the code is inside an updatepanel. As I mention in the code example, if I do not change the ddl value, in the linkbutton event, this behaviors stops but then the DDL wont have the correct value set. Here is my code:
Linkbutton event:
Protected Sub edit_click(ByVal sender As Object, ByVal e As EventArgs)
Dim btn As LinkButton = CType(sender, LinkButton)
Dim userId As String = btn.CommandArgument
Dim ds As New List(Of myObject)
Dim currentChoice As New myObject
Dim parent As RepeaterItem = CType(btn.Parent, RepeaterItem)
Dim lbl As Label = CType(parent.FindControl("userId"), Label)
Dim ma As DropDownList = CType(parent.FindControl("ddlMustApprove"), DropDownList)
Dim maLbl As Label = CType(parent.FindControl("mustApprove"), Label)
'just get a list of values to chose from
ds = Session("userNotificationDS")
currentChoice = ds.Find(Function(p As myObject) p.User.NetworkID = userId)
With maLbl
.Width = 100
.BorderColor = Drawing.Color.DarkBlue
End With
'if I disable this next line, everything works fine (but then the correct selection wont be chosen)
ma.Text = currentChoice.MustApprove
ma.CssClass = ""
maLbl.Visible = False
End Sub
DDL change event:
Protected Sub selection_Change(ByVal sender As Object, ByVal e As EventArgs)
Dim cnt As DropDownList = CType(sender, DropDownList)
Dim parent As RepeaterItem = CType(cnt.Parent, RepeaterItem)
Dim maLbl As Label = CType(parent.FindControl("mustApprove"), Label)
Dim userId As Label = CType(parent.FindControl("userId"), Label)
Dim ds As New List(Of myObject)
'just gets the value to set the DDL to
ds = Session("userNotificationDS")
For Each i As myObjectIn ds
If (i.User.NetworkID = userId.Text) Then
i.MustApprove = cnt.SelectedValue
End If
Next
maLbl.Visible = True
cnt.CssClass = "hidden"
Session("userNotificationDS") = ds
bindData(ds)
End Sub
Here is the Datarepeater in the front end code:
<asp:Repeater ID="dataRepeateUsers" runat="server" EnableViewState="false" OnItemCreated="RepeaterItemCreated" >
<HeaderTemplate>
.... column headers
</HeaderTemplate>
<ItemTemplate>
<tr class="listcolor">
<td style="border:0px; border-right:1px solid #808080 ; border-bottom:0px solid #808080;">
<asp:DropDownList runat="server" ID="ddlMustApprove" CssClass="hidden" OnTextChanged="selection_Change" EnableViewState="true" AutoPostBack="true" >
<asp:ListItem Text="True" Value="True"></asp:ListItem>
<asp:ListItem Text="False" Value="False"></asp:ListItem>
</asp:DropDownList>
<asp:label ID="mustApprove" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "MustApprove") %>'></asp:label>
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr class="listcolor">
<td style="border:0px; border-right:1px solid #808080 ; border-bottom:0px solid #808080;">
<asp:DropDownList runat="server" ID="ddlMustApprove" CssClass="hidden" OnTextChanged="selection_Change" EnableViewState="true" AutoPostBack="true" >
<asp:ListItem Text="True" Value="True"></asp:ListItem>
<asp:ListItem Text="False" Value="False"></asp:ListItem>
</asp:DropDownList>
<asp:label ID="mustApprove" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "MustApprove") %>'></asp:label>
</td>
</tr>
</AlternatingItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
My code is written in VS 2010 using .Net 4.0 and AjaxControlToolkit 4.1.60919.
Thanks
jason
ma.Text = currentChoice.MustApprove
replace this line with the following one.
if(ma.items.FindByText(currentChoice.MustApprove) != null)
{
ma.SelectedIndex = -1;
ma.items.FindByText(currentChoice.MustApprove).selected = true;
}
Just set the selectedindex of the dropdown as -1 like above.

Repeater control. Using a table that spans rows

The following "FindControl" method fails to find the imgAd control. Any idea why? Could it be the Table that contains it? The intent of the table is to line things up in columns across rows.
<asp:Content ID="Content3" ContentPlaceHolderID="phPageContent" runat="Server">
<asp:Repeater ID="repBanner" runat="server">
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:Image ID="imgAd" runat="server" AlternateText="Panda Visa" ImageUrl="Images/AffiliateBanners/125%20by%20125.jpg" />
</td>
<td>
<asp:TextBox ID="txtHtml" runat="server" Columns="80" ReadOnly="True" Rows="7" TextMode="MultiLine"></asp:TextBox>
</td>
<td>
<asp:Button runat="server" Text="Copy HTML to Clipboard" OnClientClick="ClipBoard('txtHtml')" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
Protected Sub repBanner_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles repBanner.ItemDataBound
Dim CurrentAd As Ad = CType(e.Item.DataItem, Ad)
Dim RepeaterItem As RepeaterItem = e.Item
Dim imgAd As Image = CType(RepeaterItem.FindControl("imgAd"), Image)
imgAd.ImageUrl = "Images/" & "125 by 125.jpg" '<<<Error occurs here
End Sub
Object reference not set to an instance of an object.
Here's some debug info that I thought may help:
? RepeaterItem.Controls.Count
1
? RepeaterItem.Controls(0).Controls.Count
0
? typename(RepeaterItem.Controls(0))
"LiteralControl"
You need to check e.Item.ItemType to make sure that you're dealing with an item, not a header or footer. Something like this:
Protected Sub repBanner_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles repBanner.ItemDataBound
If (e.Item.ItemType <> ListItemType.Item AndAlso e.Item.ItemType <> ListItemType.AlternatingItem) Then
Return
End If
Dim CurrentAd As Ad = CType(e.Item.DataItem, Ad)
Dim RepeaterItem As RepeaterItem = e.Item
Dim imgAd As Image = CType(RepeaterItem.FindControl("imgAd"), Image)
imgAd.ImageUrl = "Images/" & "125 by 125.jpg" '<<<Error occurs here
End Sub

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%" >
<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>
<asp:LinkButton ID="lnkPrevious" runat="server" ForeColor="Black" Text="Previous" >
</asp:LinkButton> Now Showing Page
<asp:DropDownList ID="ddlpageNumbers" runat="server" AutoPostBack="true" >
</asp:DropDownList> of <asp:Label ID="lblTotalPages" runat="server"> </asp:Label>
Pages.
<asp:LinkButton ID="lnkNext" runat="server" ForeColor="Black" Text="Next" >
</asp:LinkButton>
<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

Resources