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

DataList and SelectedItem

Hello!

I am building a navigation menu using DataList and templates. I have spent
hours trying to find a solution to my problem, but without any luck. Maybe
someone knows how to solve this problem...?

Here is what I need to achieve...

If ItemType is Item, print: "Item Name >"
If ItemType is SelectedItem, print: "Item Name <"
Thank you in advance!
Scott
Below is my code...

<asp:DataList id="dlMenuItems" runat="server" Width="180" BorderWidth="0"
DataKeyField="ID">
<SelectedItemTemplate>
<asp:HyperLink id="hlSelectedMenuItem" Runat="Server"></asp:HyperLink>
</SelectedItemTemplate>
<ItemTemplate>
<asp:HyperLink id="hlMenuItem" Runat="Server"></asp:HyperLink>
</ItemTemplate>
</asp:DataList>
Private Sub DataList1_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataListItemEventArgs) Handles
dlMenuItems.ItemDataBound

Dim hlSelectedMenuItem As HyperLink
Dim hlMenuItem As HyperLink

hlSelectedMenuItem = CType(e.Item.FindControl("hlSelectedMenuItem"),
HyperLink)
hlMenuItem = CType(e.Item.FindControl("hlMenuItem"), HyperLink)

Dim drv As DataRowView = CType(e.Item.DataItem, DataRowView)

If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
ListItemType.AlternatingItem Then

If Not drv Is Nothing Then
hlMenuItem.Text = drv("CategoryNameEst") & ">"
hlMenuItem.NavigateUrl = "../Browse.aspx?CatId=" & drv("ID")
End If

End If

If e.Item.ItemType = ListItemType.SelectedItem Then

If Not drv Is Nothing Then
hlSelectedMenuItem.Text = drv("CategoryNameEst") & "<"
hlSelectedMenuItem.NavigateUrl = "../Browse.aspx?tId=" &
drv("ID")
End If

End If

End Sub
Nov 21 '05 #1
0 904

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

Similar topics

0
by: cmcilvoy | last post by:
How do i attach onitemdatabound or any event handler to a datalist nested in a repeater? /*code ***************************************************/ <asp:repeater EnableViewState="False"...
8
by: MattB | last post by:
I think I'm close to making this work, but so far it does not. I have a datalist (id = "dlVFields") on a web form that has an item template with a textbox in it. The textbox id = "txtVerify"....
1
by: Scott Reynolds | last post by:
Hello! I am building a navigation menu using DataList and templates. I have spent hours trying to find a solution to my problem, but without any luck. Maybe someone knows how to solve this...
3
by: sling blade | last post by:
Hi, I have a dropdownlist in my DataList control and I am trying to set the SelectedItem property of the dropdownlist so when the datalist displays the user will see the text in the dropdownlist...
2
by: Jules_Anime | last post by:
Is it possible to create an onclick event which is attached to individual datalist items? I have a Datalist with some details on employees, and when you click on one we would like to open a new...
6
by: Zeba | last post by:
Hi, I have a page with a calendar and two datalist items - one containing month values and the other, year values. Depending on the month/year value chosen ( in text/string format ) I should be...
0
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, i have a simple datalist on my web page that's attached to a sqldatasource that i specified on the quick task menu for the datalist. The datalist contains a linkbutton (command name =...
1
by: Nathan Sokalski | last post by:
I have a custom Control that I have made that contains a DataList. In either the ItemCommand or SelectedIndexChanged event I need to retrieve a value from the DataItem of the SelectedItem. I have...
1
by: Skinnypig | last post by:
Hi, there will be an error-Object reference not set to an instance of an object. whenever i tried to insert item in the datalist to my shopping cart. Can anyone help? I think the error is at...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
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,...
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
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...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.