That is actually where it started out. I tried moving them around to see if that was the cause of the problem, but alas there was no improvement.
Main Topics
Browse All TopicsI've got a problem with a DataList that I am using in a user control for a kind of navigation system. My problem is that the selected item style is applied to the item, but it still uses the item template to load the controls. I am using .Net 1.1 and listed below is the html for the user control.
<div align=left style="width: 100%; background-color: #E5D797;">
<asp:datalist id="SubMenu" CssClass="SubMenu" RepeatDirection="Horizonta
<SelectedItemTemplate>
<%# CType(Container.DataItem, TabItem).Name %>
</SelectedItemTemplate>
<SelectedItemStyle CssClass="SubSelectedItem"
<ItemStyle CssClass=SubItem></ItemSty
<ItemTemplate>
<a class=NavigationLink href="<%# CType(Container.DataItem, TabItem).Path %>"><%# CType(Container.DataItem, TabItem).Name %></a>
</ItemTemplate>
</asp:datalist>
</div>
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
It never ceases to amaze me about how many ways there are to solve the same problem. Here's how I solved the a similar problem except I was needing the different CSS layout in the <EditItemTemplate>. The concepts should be the same even though the actual code is different.
<head>
<style type="text/css">
.hr {color: black;font-size: 9px}
td.happyborder {border: 5px dashed black; background-color:light-gra
</style>
</head>
<asp:DataList runat="server" Id="datalist1" Font-Size="5pt">
<ItemTemplate>
<%# DataBinder.Eval(Container.
</itemtemplate>
<EditItemTemplate>
<table>
<tr>
<td class="happyborder" valign=top style="background-color: #CCCCCC">
<asp:textbox id="yourfield_" runat="server" cssclass="hr" text='<%# DataBinder.Eval(Container.
</td>
</tr>
</table>
</EditItemTemplate>
</asp:datalist>
I hope this helps!
Kittrick
Alternatively, you might want to try:
<asp:DataList id="whatever" runat="server" >
<!----this code was missing from your orig. code or out of order--->
<SelectedItemStyle BackColor="Yellow">
</SelectedItemStyle>
<!----this code was missing from your orig. code or out of order--->
<HeaderTemplate>
Items
</HeaderTemplate>
<ItemTemplate>
</ItemTemplate>
<SelectedItemTemplate>
</SelectedItemTemplate>
</asp:DataList>
I found this in the example at:
http://msdn.microsoft.com/
Kittrick
Business Accounts
Answer for Membership
by: KittrickPosted on 2006-06-28 at 16:11:50ID: 17005697
Hi there,
t/QuickSta rt/util/sr cview.aspx ? path=~/as pnet/sampl es/ctrlref /data/Data List/DataL ist2.src
I found an example at:
http://webmatrixproject.ne
Where it shows the <SelectedItemTemplate>, and it's after the <ItemTemplate>, whereas in your code yours is before. I've found about 3 other MS sites that showed the same thing.
<asp:DataList id="whatever" runat="server" >
<HeaderTemplate>
Items
</HeaderTemplate>
<ItemTemplate>
</ItemTemplate>
<SelectedItemTemplate>
</SelectedItemTemplate>
</asp:DataList>
Hopefully this solves your problem!
Kittrick