By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,524 Members | 1,519 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,524 IT Pros & Developers. It's quick & easy.

DataList and SelectedItem

P: n/a

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!
Below is my code...

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

Dim hlSelectedMenuItem As HyperLink
Dim hlMenuItem As HyperLink

hlSelectedMenuItem = CType(e.Item.FindControl("hlSelectedMenuItem"),
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=" &
End If

End If

End Sub
Nov 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.