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

Repeaters and SiteMapDataSources

Hi guys,

im trying to do something which I feel isn't that difficult. I'm just a
little lost in the .net framework. Here goes...

I have a repeater which is using a SiteMapDataSource to bind to. I am trying
to make my own custom navigation system. All in all it works fine. I simply
create a new <asp:HyperLinkfor each new entry and use the
<SeperoratorTemplateto format how it all appears.

However, I would like to display the style of the selected page differently.
I.e. For the page the user is currently visiting, I want the HyperLink to
use a different CSS style than the rest. I can't quite figure out how todo
this. I have a feeling I need catch an event, either from the Repeater
control or the hyperlink, however im not sure what todo and what properties
to check for.

Any help in this matter would be really appreciated!

Thank you!
Taz
Sep 13 '06 #1
2 3501
Tarun,

In the repeator ItemDataBound event you can "change things". For example:
<asp:Repeater
ID="Repeater1"
runat="server"
DataSourceID="SqlDataSource1"
OnItemDataBound="Repeater1_ItemDataBound">
<ItemTemplate>
<asp:HyperLink
ID="a"
runat="server"
CssClass="b"
NavigateUrl="~/Default.aspx">ggg</asp:HyperLink>
</ItemTemplate>
</asp:Repeater>

protected void Repeater1_ItemDataBound(
object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item
|| e.Item.ItemType == ListItemType.AlternatingItem)
{
HyperLink a = (HyperLink)e.Item.FindControl("a");
if (Page.ResolveUrl(a.NavigateUrl)
== Request.Url.AbsolutePath)
{
a.CssClass = "ddd";
}
}
}
Regards,

Rob

"Tarun Mistry" <no****@nospam.comwrote in message
news:eV**************@TK2MSFTNGP03.phx.gbl...
Hi guys,

im trying to do something which I feel isn't that difficult. I'm just a
little lost in the .net framework. Here goes...

I have a repeater which is using a SiteMapDataSource to bind to. I am
trying to make my own custom navigation system. All in all it works fine.
I simply create a new <asp:HyperLinkfor each new entry and use the
<SeperoratorTemplateto format how it all appears.

However, I would like to display the style of the selected page
differently. I.e. For the page the user is currently visiting, I want the
HyperLink to use a different CSS style than the rest. I can't quite figure
out how todo this. I have a feeling I need catch an event, either from the
Repeater control or the hyperlink, however im not sure what todo and what
properties to check for.

Any help in this matter would be really appreciated!

Thank you!
Taz

Sep 13 '06 #2
Absolutely perfect!

I was trying todo something similar but wasnt sure how to access the
hyperlink or the sitemap.

Thanks you so much!

Kind regards
Taz

"Rob MacFadyen" <rmacfadyen_at_gmail.comwrote in message
news:On**************@TK2MSFTNGP02.phx.gbl...
Tarun,

In the repeator ItemDataBound event you can "change things". For example:
<asp:Repeater
ID="Repeater1"
runat="server"
DataSourceID="SqlDataSource1"
OnItemDataBound="Repeater1_ItemDataBound">
<ItemTemplate>
<asp:HyperLink
ID="a"
runat="server"
CssClass="b"
NavigateUrl="~/Default.aspx">ggg</asp:HyperLink>
</ItemTemplate>
</asp:Repeater>

protected void Repeater1_ItemDataBound(
object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item
|| e.Item.ItemType == ListItemType.AlternatingItem)
{
HyperLink a = (HyperLink)e.Item.FindControl("a");
if (Page.ResolveUrl(a.NavigateUrl)
== Request.Url.AbsolutePath)
{
a.CssClass = "ddd";
}
}
}
Regards,

Rob

"Tarun Mistry" <no****@nospam.comwrote in message
news:eV**************@TK2MSFTNGP03.phx.gbl...
>Hi guys,

im trying to do something which I feel isn't that difficult. I'm just a
little lost in the .net framework. Here goes...

I have a repeater which is using a SiteMapDataSource to bind to. I am
trying to make my own custom navigation system. All in all it works fine.
I simply create a new <asp:HyperLinkfor each new entry and use the
<SeperoratorTemplateto format how it all appears.

However, I would like to display the style of the selected page
differently. I.e. For the page the user is currently visiting, I want the
HyperLink to use a different CSS style than the rest. I can't quite
figure out how todo this. I have a feeling I need catch an event, either
from the Repeater control or the hyperlink, however im not sure what todo
and what properties to check for.

Any help in this matter would be really appreciated!

Thank you!
Taz


Sep 14 '06 #3

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

Similar topics

0
by: David B | last post by:
Bare with me this is my first post. Objective: To dynamically create repeaters in a WebForm based on sets of data. Problem: When I attempt to create any Repeater from C# I get a big fat white...
3
by: DonRex | last post by:
Hello all! I couldn't find a web application-newsgroup for ASP.NET, so I'm sorry if this is the wrong forum! Synopsis: In my webform I have 3 nested repeaters: rpWeeks ----- rpTime
0
by: Paul | last post by:
I want to be able to nest a repeater in a datagrid or datalist. I'm not unduly bothered about a master/child relationship as such as there'll at this stage only ever be one record on the page, but...
0
by: Machi | last post by:
let say in parent-child scenerio (Product: Product Category - one product category may has many products), i am using nested repeaters where parent repeater will be used to display info and child...
0
by: kettch | last post by:
Is it possible to have nested repeaters three layers deep I have gotten it to work with only two, and when I tried to get the third layer to work COD <asp:repeater id="rep"...
1
by: garethdjames | last post by:
Please can some on offer some practicle advice, I am designing a page that displays details about a product, the page will be navigated from a datagrid (this bit no problem), The details page...
1
by: Roy | last post by:
No errors here, I'm just looking for ways to make my code more efficient. As the subject line suggests, I have a LOT of repeaters on a certain page. They are visible or hidden depending on user...
1
PrinsonG
by: PrinsonG | last post by:
My Query is How do I export to excel/csv using Nested Repeaters. My project is web-based and i am using C#.Net. In this i use three repeaters. one displays ID, Name of the user. second...
1
by: andrew.douglas11 | last post by:
Hello all, Is it possible to share controls inside a child repeater? Here's the situation: I have a web page that needs to display data grouped by A, and alternatively by B (only one grouping...
3
by: Leon Mayne | last post by:
If I have a datatable which looks like this: Record Id, Group Id, Name 1, 1, Test 1 2, 1, Test 2 3, 2, Test 3 4, 3, Test 4 Is it possible to use nested repeaters to group the information by...
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: 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?
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
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.