473,385 Members | 1,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

repeater control last row

Sir,

According to our design, very often, I need to have a different html code
for the last row of our repeater control. I can not put those code
difference into footer because those code has to be in the last data row.

How can I edit the last data row of a repeater control??

--
Kind regards

Guoqi Zheng
guoqi AT meetholland dot com
Http://www.meetholland.com

Nov 18 '05 #1
3 3295
Create your own repeater control, inheriting
System.Web.UI.WebControls.Repeater and then implement your ITemplate. In
the ITemplate, you can add code to respond to whatever conditions dictate
the HTML code and provide the right output.

Here's a link for a simple custom repeater that will give you a place to
start:

http://coltkwong.com/blogs/juliet/posts/467.aspx

Dale Preston
MCAD, MCSE, MCDBA

"Guoqi Zheng" <no@sorry.nl> wrote in message
news:ub**************@TK2MSFTNGP10.phx.gbl...
Sir,

According to our design, very often, I need to have a different html code
for the last row of our repeater control. I can not put those code
difference into footer because those code has to be in the last data row.

How can I edit the last data row of a repeater control??

--
Kind regards

Guoqi Zheng
guoqi AT meetholland dot com
Http://www.meetholland.com

Nov 18 '05 #2
Hi Guoqi,

In the Page object's PreRender event you already know how many items there
are in the repeater. Therefore, you can get a reference to the last item and
do whatever needs to be done with it. Here's a snippet, full source below:

Private Sub Page_PreRender _
(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles MyBase.PreRender
Dim itm As RepeaterItem
itm = Repeater1.Items(Repeater1.Items.Count - 1)
Dim lblNotice As New Label
lblNotice.Text = "Last>>>"
itm.Controls.AddAt(0, lblNotice)
End Sub

Does this help?

Ken
Microsoft MVP [ASP.NET]
Toronto
Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim lblCntrl As Label
Repeater1.DataSource = CreateDataSource()
Repeater1.DataMember = "StringValue"
Repeater1.DataBind()

End Sub

Private Sub Page_PreRender _
(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles MyBase.PreRender
Dim itm As RepeaterItem
itm = Repeater1.Items(Repeater1.Items.Count - 1)
Dim lblNotice As New Label
lblNotice.Text = "Last>>>"
itm.Controls.AddAt(0, lblNotice)
End Sub

Function CreateDataSource() As DataTable
Dim dt As New DataTable
Dim dr As DataRow
dt.Columns.Add(New DataColumn _
("IntegerValue", GetType(Int32)))
dt.Columns.Add(New DataColumn _
("StringValue", GetType(String)))
dt.Columns.Add(New DataColumn _
("CurrencyValue", GetType(Double)))
dt.Columns.Add(New DataColumn _
("Boolean", GetType(Boolean)))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 1.23 * (i + 1)
dr(3) = (i = 4)
dt.Rows.Add(dr)
Next i
Return dt
End Function 'CreateDataSource

<asp:Repeater id="Repeater1" runat="server">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>

<asp:Label id="Label3" runat="server">
<%# DataBinder.Eval(Container, "DataItem.StringValue") %>
</asp:Label>
<br>
</ItemTemplate>
</asp:Repeater>
"Guoqi Zheng" <no@sorry.nl> wrote in message
news:ub**************@TK2MSFTNGP10.phx.gbl...
Sir,

According to our design, very often, I need to have a different html code
for the last row of our repeater control. I can not put those code
difference into footer because those code has to be in the last data row.

How can I edit the last data row of a repeater control??

--
Kind regards

Guoqi Zheng
guoqi AT meetholland dot com
Http://www.meetholland.com


Nov 18 '05 #3
Thanks, that sounds like what I am after, I will try it out.

--
Kind regards

Guoqi Zheng
guoqi AT meetholland dot com
Http://www.meetholland.com

"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:Op**************@TK2MSFTNGP09.phx.gbl...
Hi Guoqi,

In the Page object's PreRender event you already know how many items there
are in the repeater. Therefore, you can get a reference to the last item and do whatever needs to be done with it. Here's a snippet, full source below:

Private Sub Page_PreRender _
(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles MyBase.PreRender
Dim itm As RepeaterItem
itm = Repeater1.Items(Repeater1.Items.Count - 1)
Dim lblNotice As New Label
lblNotice.Text = "Last>>>"
itm.Controls.AddAt(0, lblNotice)
End Sub

Does this help?

Ken
Microsoft MVP [ASP.NET]
Toronto
Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim lblCntrl As Label
Repeater1.DataSource = CreateDataSource()
Repeater1.DataMember = "StringValue"
Repeater1.DataBind()

End Sub

Private Sub Page_PreRender _
(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles MyBase.PreRender
Dim itm As RepeaterItem
itm = Repeater1.Items(Repeater1.Items.Count - 1)
Dim lblNotice As New Label
lblNotice.Text = "Last>>>"
itm.Controls.AddAt(0, lblNotice)
End Sub

Function CreateDataSource() As DataTable
Dim dt As New DataTable
Dim dr As DataRow
dt.Columns.Add(New DataColumn _
("IntegerValue", GetType(Int32)))
dt.Columns.Add(New DataColumn _
("StringValue", GetType(String)))
dt.Columns.Add(New DataColumn _
("CurrencyValue", GetType(Double)))
dt.Columns.Add(New DataColumn _
("Boolean", GetType(Boolean)))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 1.23 * (i + 1)
dr(3) = (i = 4)
dt.Rows.Add(dr)
Next i
Return dt
End Function 'CreateDataSource

<asp:Repeater id="Repeater1" runat="server">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>

<asp:Label id="Label3" runat="server">
<%# DataBinder.Eval(Container, "DataItem.StringValue") %>
</asp:Label>
<br>
</ItemTemplate>
</asp:Repeater>
"Guoqi Zheng" <no@sorry.nl> wrote in message
news:ub**************@TK2MSFTNGP10.phx.gbl...
Sir,

According to our design, very often, I need to have a different html code for the last row of our repeater control. I can not put those code
difference into footer because those code has to be in the last data row.
How can I edit the last data row of a repeater control??

--
Kind regards

Guoqi Zheng
guoqi AT meetholland dot com
Http://www.meetholland.com

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: simon | last post by:
I have a dataRepeater control on a page, which lists me the headers of a news. When I click on a header I would like to show the news for this header. Which is the best practice? Have an anhor...
5
by: Martin Dew | last post by:
Having some problems getting a hyperlink object to work in my repeater control, It displays the text I have asked it to for the hyperlink, but it does not act as a link. My repeater code is below...
0
by: Guoqi Zheng | last post by:
Sir, A few days ago, I asked a question about how to insert something into the last row of a repeater control. I got the following code from Ken, Private Sub Page_PreRender (ByVal sender As...
3
by: WebMatrix | last post by:
I am struggling with implementing somewhat complicated UI web-control. I explored Repeater, but I am not sure if it's the best way to go. I am leaning towards writing my own custom control and...
7
by: charliewest | last post by:
Hello - I'm using a Repeater control to render information in a very customized grid-like table. The Repeater control is binded to a DataSet with several records of information. Within the...
3
by: Andrew | last post by:
Hi, I am working on a questionnaire. I have displayed a questionnaire using a repeater control. The itemtemplate is as below (quite cut down): <ItemTemplate> <tr><td> <%#...
3
by: renil | last post by:
I have a repeater control that displays info. from a datatable. Each row in the repeater has a checkbox. Also, I have a delete linkbutton outside the repeater control. What I'm trying to do when...
7
by: | last post by:
I have what's probably a simple page lifecycle question related to dynamically evaluating values that are placed by a repeater and dynmically placing user controls that use those values. I'm...
3
by: shapper | last post by:
Hello, I am created an Asp.Net 2.0 repeater implementing the ITemplate class. I know my datasource, a datatable has 6 rows, but the repeater only displays the last one. If I add more rows...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.