473,782 Members | 2,534 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3449
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.Fo reColor = "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
"dhnriversi de" 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='<%# (SourceDataTabl e.Rows.Count==( Container.ItemI ndex+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

"dhnriversi de" <da*@musoswire. com> wrote in message
news:4D******** *************** ***********@mic rosoft.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

"dhnriversi de" <da*@musoswire. com> wrote in message
news:4D******** *************** ***********@mic rosoft.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

"dhnriversi de" <da*@musoswire. com> wrote in message
news:4D******** *************** ***********@mic rosoft.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.W ebControls.Data GridItemEventAr gs) {} but that didn't work
(cant use DataGridItemEve ntArgs with a repeater!). So I changed it to
RepeaterItemEve ntArgs, but I'm struggling to convert my e.Item to a
DataGridItem..

System.Web.UI.W ebControls.Data GridItem 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.Fo reColor = "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
"dhnriversi de" 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.W ebControls.Repe aterItem insted of DataGridItem

"dhnriversi de" 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.W ebControls.Data GridItemEventAr gs) {} but that didn't work
(cant use DataGridItemEve ntArgs with a repeater!). So I changed it to
RepeaterItemEve ntArgs, but I'm struggling to convert my e.Item to a
DataGridItem..

System.Web.UI.W ebControls.Data GridItem 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.Fo reColor = "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
"dhnriversi de" 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.W ebControls.Repe aterItem insted of DataGridItem

"dhnriversi de" 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.W ebControls.Data GridItemEventAr gs) {} but that didn't work
(cant use DataGridItemEve ntArgs with a repeater!). So I changed it to
RepeaterItemEve ntArgs, but I'm struggling to convert my e.Item to a
DataGridItem..

System.Web.UI.W ebControls.Data GridItem 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.Fo reColor = "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
"dhnriversi de" 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

"dhnriversi de" <da*@musoswire. com> wrote in message
news:B1******** *************** ***********@mic rosoft.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

"dhnriversi de" <da*@musoswire. com> wrote in message
news:4D******** *************** ***********@mic rosoft.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
1601
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> <%# DataBinder.Eval(Container.DataItem, "Key") %> = <%# DataBinder.Eval(Container.DataItem, "Value") %> </ItemTemplate> </AlternatingItemTemplate> </asp:Repeater>
2
3808
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 webpage where the user can enter some search criteria (via dropdowns and textboxes) and then perform a search and have results presented. The results list includes linkbuttons which the user can click on to obtain more detailed results.
5
8279
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 source code. If you want me to post code, though, just say so. In a nutshell, I've got an ASP.NET application that has one main ASPX page. On that ASPX page, it has a user control (an ASCX) that displays the actual data and controls I need.
4
3649
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 Eric Gerbil 1 Eric Bird 10
3
2055
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. However, when the user clicks a save button (not in the asp:repeater, but on the form itself) I would like to (on postback) update the values in the database and redisplay the page. I can't figure out how to reference the controls generated by...
3
2548
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 Hashtable. Originally my code was: <asp:Repeater id="rptFamily" runat="server" DataSource="<%# family %>"> <ItemTemplate> <%# DataBinder.Eval(Container.DataItem, "Key") %> = <%# DataBinder.Eval(Container.DataItem, "Value") %>
1
4908
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 I try to give the repeater values by removing if (!IsPostBack) {} from the
1
17048
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 control in my aspx page with two image buttons, one for an edit command, another a delete command. Here is a cut down code fragment. ...
2
3880
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" /><br /> <label... <label... <label...
0
9641
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10146
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10080
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.