DataList and css class

S

sameer

Hi,

i am having a pretty strange problem here, My left menu is an ascx control
which has 3 datalist in it each containing subcategories. ADO.net Datatables
are bound to these datagrids when the page loads and in the html page of ascx
code of the menu control i have the follwing piece of code but repeated 2
more times for other categories( of course name of controls are all different)

<asp:datalist id="MyList" EnableViewState="false"
SelectedItemStyle-BackColor="dimgray" width="145" cellspacing="0"
cellpadding="0" runat="server">
<SelectedItemStyle BackColor="Transparent"></SelectedItemStyle>
<HeaderTemplate>
Test
</HeaderTemplate>
<SelectedItemTemplate>
<asp:HyperLink id=HyperLink2 runat="server" NavigateUrl='<%
"productslist.aspx?CategoryID=" & DataBinder.Eval(Container.DataItem,
"CategoryID") & "&selection=" & Container.ItemIndex %>'
cssclass="MenuSelected" Text='<%# DataBinder.Eval(Container.DataItem,
"CategoryName") %>'>
</asp:HyperLink>
</SelectedItemTemplate>
<ItemStyle Height="20px"></ItemStyle>
<ItemTemplate>
<asp:HyperLink id=HyperLink1 runat="server" NavigateUrl='<%#
"productslist.aspx?CategoryID=" & DataBinder.Eval(Container.DataItem,
"CategoryID") & "&selection=" & Container.ItemIndex %>'
cssclass="MenuUnselected" Text='<%# DataBinder.Eval(Container.DataItem,
"CategoryName") %>'>
</asp:HyperLink>
</ItemTemplate>
<HeaderStyle CssClass="MenuSelected2" BackColor="DimGray"></HeaderStyle>
</asp:datalist>
When i click on a subcategory item which is in the 3rd list, i see the rigth
contents being pulled frm the database but i also expect the subcategory that
i have selected to look like what the css class it is set to which is
MenuSelected but what is happening is that the subcategory with the same
sequnce no( lets say i selected the 3rd item in the bottom most gird, so the
3 rd item from the top most grid(always topmost)) is being the set clss class.

when i took out the piece of code (which is & "&selection=" &
Container.ItemIndex) from the <SelectedItemTemplate> and <ItemTemplate> 's
Hyperlinks this behavior does not happen any more but i as well loose the
feature of the subcategory being highligted (since it has the css class
"MenuSelected" which sets a differnte size and font of the category) when the
user clicks on it.

can any body suggest why this is happennig and how can i possibly fix this
issue so that when i click a subacategory of a certain list, only it shold be
set the menuselected clss class and not the one from the top most list.

Please help. if i am not clear , shoot me a question.

Sameer
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top