473,383 Members | 1,892 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,383 software developers and data experts.

highlight 1 row in asp:repeater

Hi

I'm using an asp:repeater and its DataSource/DataBind system to show a
number of records from the database. I want to highlight the latest record
(which will be the highest ID).

Any thoughts on how to do this with the repeater?

Cheers
Dan
Nov 19 '05 #1
8 3427
handle the OnItemDataBound event. Set a variable ID = 0 and if the "Id" of
the current item in the handler is greater than ID, set a DataGridItem = this
current item. Then set something like datagriditem.ForeColor = "Red"...

It's not the best of explanation, but I don't have much time to write you a
code snippet. If you don't understand, ask again.

Hope that helps!
Regards,
Kostadin Kostov
"dhnriverside" wrote:
Hi

I'm using an asp:repeater and its DataSource/DataBind system to show a
number of records from the database. I want to highlight the latest record
(which will be the highest ID).

Any thoughts on how to do this with the repeater?

Cheers
Dan

Nov 19 '05 #2
I assumed that you would change the class attribute of a table row.
<asp:repeater DataSource="<%# SourceDataTable%>" >
<ItemTemplate>
<tr class='<%# (SourceDataTable.Rows.Count==(Container.ItemIndex+ 1)) ?
"Selected" : "" %>'>
<td> </td>
</tr>
</ItemTemplate>
</asp:repeater>

I think, something like this would help u.

Handling events is not my way. I am not sure, but i believe this is
faster... Am I Right ?

--
Thanks,
Yunus Emre ALPÖZEN

"dhnriverside" <da*@musoswire.com> wrote in message
news:4D**********************************@microsof t.com...
Hi

I'm using an asp:repeater and its DataSource/DataBind system to show a
number of records from the database. I want to highlight the latest record
(which will be the highest ID).

Any thoughts on how to do this with the repeater?

Cheers
Dan

Nov 19 '05 #3
In PreRender event you have access to all repeater items when they already
have been built. You can loop through the data items, find the one with the
highest id (or just go to the last item if they are already sorted by id)
and change its visual properties as you wish.

Eliyahu

"dhnriverside" <da*@musoswire.com> wrote in message
news:4D**********************************@microsof t.com...
Hi

I'm using an asp:repeater and its DataSource/DataBind system to show a
number of records from the database. I want to highlight the latest record
(which will be the highest ID).

Any thoughts on how to do this with the repeater?

Cheers
Dan

Nov 19 '05 #4
Hiya

How do I do that? Im looking at OPR now, presumably I use rptBlah.Items[x].
but I cant find anything to change anything in the HTML!

Ta

"Eliyahu Goldin" wrote:
In PreRender event you have access to all repeater items when they already
have been built. You can loop through the data items, find the one with the
highest id (or just go to the last item if they are already sorted by id)
and change its visual properties as you wish.

Eliyahu

"dhnriverside" <da*@musoswire.com> wrote in message
news:4D**********************************@microsof t.com...
Hi

I'm using an asp:repeater and its DataSource/DataBind system to show a
number of records from the database. I want to highlight the latest record
(which will be the highest ID).

Any thoughts on how to do this with the repeater?

Cheers
Dan


Nov 19 '05 #5
Hiya

That makes snse. However I'm struggling a bit to implement it

I created a function

private void CCItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs) {} but that didn't work
(cant use DataGridItemEventArgs with a repeater!). So I changed it to
RepeaterItemEventArgs, but I'm struggling to convert my e.Item to a
DataGridItem..

System.Web.UI.WebControls.DataGridItem dgItem;
dgItem = e.Item;

Wont let me do that! Any suggestions on how to get the e.Item to dgItem, so
I can use tihngs like .Font which arent available in e.Item ?

Cheers
Dan


"Kostadin Kostov" wrote:
handle the OnItemDataBound event. Set a variable ID = 0 and if the "Id" of
the current item in the handler is greater than ID, set a DataGridItem = this
current item. Then set something like datagriditem.ForeColor = "Red"...

It's not the best of explanation, but I don't have much time to write you a
code snippet. If you don't understand, ask again.

Hope that helps!
Regards,
Kostadin Kostov
"dhnriverside" wrote:
Hi

I'm using an asp:repeater and its DataSource/DataBind system to show a
number of records from the database. I want to highlight the latest record
(which will be the highest ID).

Any thoughts on how to do this with the repeater?

Cheers
Dan

Nov 19 '05 #6
Try using System.Web.UI.WebControls.RepeaterItem insted of DataGridItem

"dhnriverside" wrote:
Hiya

That makes snse. However I'm struggling a bit to implement it

I created a function

private void CCItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs) {} but that didn't work
(cant use DataGridItemEventArgs with a repeater!). So I changed it to
RepeaterItemEventArgs, but I'm struggling to convert my e.Item to a
DataGridItem..

System.Web.UI.WebControls.DataGridItem dgItem;
dgItem = e.Item;

Wont let me do that! Any suggestions on how to get the e.Item to dgItem, so
I can use tihngs like .Font which arent available in e.Item ?

Cheers
Dan


"Kostadin Kostov" wrote:
handle the OnItemDataBound event. Set a variable ID = 0 and if the "Id" of
the current item in the handler is greater than ID, set a DataGridItem = this
current item. Then set something like datagriditem.ForeColor = "Red"...

It's not the best of explanation, but I don't have much time to write you a
code snippet. If you don't understand, ask again.

Hope that helps!
Regards,
Kostadin Kostov
"dhnriverside" wrote:
Hi

I'm using an asp:repeater and its DataSource/DataBind system to show a
number of records from the database. I want to highlight the latest record
(which will be the highest ID).

Any thoughts on how to do this with the repeater?

Cheers
Dan

Nov 19 '05 #7
I have, but how do I change anything with that? It doesnt appear to have a
Font property, or a BackColor property, or anything like InnerHtml. Help! :o)
"Kostadin Kostov" wrote:
Try using System.Web.UI.WebControls.RepeaterItem insted of DataGridItem

"dhnriverside" wrote:
Hiya

That makes snse. However I'm struggling a bit to implement it

I created a function

private void CCItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs) {} but that didn't work
(cant use DataGridItemEventArgs with a repeater!). So I changed it to
RepeaterItemEventArgs, but I'm struggling to convert my e.Item to a
DataGridItem..

System.Web.UI.WebControls.DataGridItem dgItem;
dgItem = e.Item;

Wont let me do that! Any suggestions on how to get the e.Item to dgItem, so
I can use tihngs like .Font which arent available in e.Item ?

Cheers
Dan


"Kostadin Kostov" wrote:
handle the OnItemDataBound event. Set a variable ID = 0 and if the "Id" of
the current item in the handler is greater than ID, set a DataGridItem = this
current item. Then set something like datagriditem.ForeColor = "Red"...

It's not the best of explanation, but I don't have much time to write you a
code snippet. If you don't understand, ask again.

Hope that helps!
Regards,
Kostadin Kostov
"dhnriverside" wrote:

> Hi
>
> I'm using an asp:repeater and its DataSource/DataBind system to show a
> number of records from the database. I want to highlight the latest record
> (which will be the highest ID).
>
> Any thoughts on how to do this with the repeater?
>
> Cheers
>
>
> Dan

Nov 19 '05 #8
With the Repeater you are free to make any items. Once you get a reference
to the item, only you know what to do with it. What is the meaning of
"highlight"? It depends on what is inside the item.

Eliyahu

"dhnriverside" <da*@musoswire.com> wrote in message
news:B1**********************************@microsof t.com...
Hiya

How do I do that? Im looking at OPR now, presumably I use rptBlah.Items[x]. but I cant find anything to change anything in the HTML!

Ta

"Eliyahu Goldin" wrote:
In PreRender event you have access to all repeater items when they already have been built. You can loop through the data items, find the one with the highest id (or just go to the last item if they are already sorted by id) and change its visual properties as you wish.

Eliyahu

"dhnriverside" <da*@musoswire.com> wrote in message
news:4D**********************************@microsof t.com...
Hi

I'm using an asp:repeater and its DataSource/DataBind system to show a
number of records from the database. I want to highlight the latest record (which will be the highest ID).

Any thoughts on how to do this with the repeater?

Cheers
Dan


Nov 19 '05 #9

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

Similar topics

0
by: Joe Fawcett | last post by:
I'm having a problem binding an asp:repeater control to a Hashtable. Originally my code was: <asp:Repeater id="rptFamily" runat="server" DataSource="<%# family %>"> <ItemTemplate> <%#...
2
by: Peter Kirk | last post by:
Hi are there any "gotchas" with using an asp:repeater that means that the "onclick" method of a LinkButton created in the repaeter does not fire? I at least cannot get it to work. I have a...
5
by: Scott Lyon | last post by:
I am having a strange problem. The program is a bit complex, but I'll try to simplify what I can. I apologize if this is complicated, but I think this would still be simpler than posting a bunch of...
4
by: Eric | last post by:
Hello, I have the following dataset that I want to bind to a repeater to be displayed as a table. Owner Animal Volume --------------------------- Eric Dog 6 Eric Cat ...
3
by: Kelly Leahy | last post by:
I'm using an Asp:Repeater control with a text box in the item templates. This is for a system that has a number of items that the user can edit and I'd like to generate them based on a list. ...
3
by: Joe Fawcett | last post by:
Sorry about the multi post, I thought I'd sent to both groups simultaneously but somehow it failed to find this one the first time. I'm having a problem binding an asp:repeater control to a...
1
by: Fred Dag | last post by:
As far as I can work out when using the OnTextChanged event I cannot get the TextBox and Labels values when the event fires as they are populated by a <asp:repeater and so don't have values. If...
1
by: Timbo | last post by:
Hi all, This is my first message here so i'll try and include all the information that will help you help me out, if possible. Basically I am using C# in ASP.NET 2.0 and have a Repeater...
2
by: bissatch | last post by:
Hi, I am trying to output a list of checkboxes. Using ASP .NET controls, I was able to create the following: <label for="colour_red">Red: </label><asp:CheckBox ID="colour_red" runat="server"...
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
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
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.