473,320 Members | 2,073 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,320 software developers and data experts.

getting the record count within a repeater control

I have a repeater that I'd like to apply some logic to, namly highlighting
the top few items in the repeater. To do this, I need to determine the
record count.

I've tried this:

<%
dim highlightCount as integer = 1
%>

<asp:Repeater id="Repeater1" runat="server">
<ItemTemplate>
<%
if (highlightCount < 3) AND DataBinder.Eval(Container.DataItem,
"Highlight").tostring = "1" then...
%>

But my code within the itemTemplate can't 'see' the 'highlightCount' integer
(I get a not declared error).

So...is there a way to get the record count via the databinder.eval
function? (or is my syntax incorrect up above?)

-Darrel
Nov 19 '05 #1
4 5229
Darrel,

I'd go about this a different way...

The repeater (like the datalist and datagrid) has an OnItemDataBound event
that fires whenever a "row" of the repeater is databound. From within this
event you could easily get the row number and use your if/then to add
highlighting to that row.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"darrel" <no*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
I have a repeater that I'd like to apply some logic to, namly highlighting
the top few items in the repeater. To do this, I need to determine the
record count.

I've tried this:

<%
dim highlightCount as integer = 1
%>

<asp:Repeater id="Repeater1" runat="server">
<ItemTemplate>
<%
if (highlightCount < 3) AND DataBinder.Eval(Container.DataItem,
"Highlight").tostring = "1" then...
%>

But my code within the itemTemplate can't 'see' the 'highlightCount'
integer
(I get a not declared error).

So...is there a way to get the record count via the databinder.eval
function? (or is my syntax incorrect up above?)

-Darrel

Nov 19 '05 #2
> The repeater (like the datalist and datagrid) has an OnItemDataBound event
that fires whenever a "row" of the repeater is databound. From within this
event you could easily get the row number and use your if/then to add
highlighting to that row.


Thanks. Good tip. In the end, I figured it out by just moving all my if/then
logic into a function in the codebehind. I haven't used repeaters in a while
(i've gotten in the habit of using stringbuilders as I typically have much
more control) but decided to give a repeater control another shot.

-Darrel
Nov 19 '05 #3
Darrel,

You're welcome. Funny, I do the same thing. Often I either go all out and
use a datagrid, but otherwise use the string builder...

I've had a couple of occasions where the datalist / repeater were the
correct controls for the project though.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"darrel" <no*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
The repeater (like the datalist and datagrid) has an OnItemDataBound
event
that fires whenever a "row" of the repeater is databound. From within
this
event you could easily get the row number and use your if/then to add
highlighting to that row.


Thanks. Good tip. In the end, I figured it out by just moving all my
if/then
logic into a function in the codebehind. I haven't used repeaters in a
while
(i've gotten in the habit of using stringbuilders as I typically have much
more control) but decided to give a repeater control another shot.

-Darrel

Nov 19 '05 #4
The PreRender event is better since in that event the repeater is already
fully built and you can just loop through the items.

Eliyahu

"S. Justin Gengo" <sjgengo@[no_spam_please]aboutfortunate.com> wrote in
message news:%2***************@TK2MSFTNGP11.phx.gbl...
Darrel,

I'd go about this a different way...

The repeater (like the datalist and datagrid) has an OnItemDataBound event
that fires whenever a "row" of the repeater is databound. From within this
event you could easily get the row number and use your if/then to add
highlighting to that row.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"darrel" <no*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
I have a repeater that I'd like to apply some logic to, namly highlighting the top few items in the repeater. To do this, I need to determine the
record count.

I've tried this:

<%
dim highlightCount as integer = 1
%>

<asp:Repeater id="Repeater1" runat="server">
<ItemTemplate>
<%
if (highlightCount < 3) AND DataBinder.Eval(Container.DataItem,
"Highlight").tostring = "1" then...
%>

But my code within the itemTemplate can't 'see' the 'highlightCount'
integer
(I get a not declared error).

So...is there a way to get the record count via the databinder.eval
function? (or is my syntax incorrect up above?)

-Darrel


Nov 19 '05 #5

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

Similar topics

2
by: Jorge Ayala | last post by:
Well I'm trying to catch and act upon a button event that is placed within the item template of a repeater control. Yet the code I'm using isn't working. What I've seen out there to explain how...
8
by: Invalidlastname | last post by:
Hi, We are developing an asp.net application, and we dynamically created certain literal controls to represent some read-only text for certain editable controls. However, recently we found an issue...
1
by: MattB | last post by:
OK, never mind my last post. It was easy enough to refer to the table the repeater is bound to, but I made a big, incorrect assumption in that post. In my last post I thought I was successfully...
1
by: darrel | last post by:
I'm trying to whip up a fancy repeater control that will put records into a two-column table for me. This is how I envision it working: itemtemplate if record count = odd then write out the...
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: 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...
3
by: Jeff | last post by:
Hey ASP.NET 2.0 Below you see the code I'm having problem with. In the Open_Message event/method I want to get the value of the HiddenField at the row in the repeater control I clicked.... my...
2
by: AC [MVP MOSS] | last post by:
I have a repeater with a header, footer, and item template. The item template is the only one with server controls (hyperlinks, labels, and a nested repeater). Within the top repeater, I'm handling...
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
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
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...

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.