DataList and css class

Discussion in 'ASP .Net Web Controls' started by sameer, Jun 29, 2005.

  1. sameer

    sameer Guest

    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
     
    sameer, Jun 29, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gönen EREN

    Datalist in Datalist How?

    Gönen EREN, Aug 22, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    424
    Gönen EREN
    Aug 22, 2003
  2. acko bogicevic

    DataList in DataList

    acko bogicevic, Nov 10, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    5,569
    acko bogicevic
    Nov 11, 2003
  3. Steve Lloyd
    Replies:
    1
    Views:
    720
    Rick Spiewak
    May 26, 2004
  4. Nevyn Twyll
    Replies:
    8
    Views:
    1,966
  5. E11
    Replies:
    1
    Views:
    4,946
    Thomas Weidenfeller
    Oct 12, 2005
Loading...

Share This Page