SelectedItemTemplate is ignored

Discussion in 'ASP .Net Web Controls' started by Lubomir, Feb 26, 2005.

  1. Lubomir

    Lubomir Guest

    Hi,

    I have a datalist with the definition for ItemTeplate and
    SelectedItemTemplate.
    When an item is selected, the background color is changed according to
    SelectedItemStyle-BackColor="#66CC66" (= in a datalist's header) but the
    definition within < SelectedItemTemplate> is ignored and the < ItemTeplate>
    is used.
    When an user clicks on a datalist item, the page is navigated to the “urlâ€
    and DataList1.SelectedIndex is set up. I think so far it should be OK as
    SelectedItemStyle-BackColor is used as expected. But why is not used
    <SelectedItemTemplate> also?


    if (!IsPostBack)
    {
    BindData();
    }

    String selectionId = Request.Params["recordNo"];
    if (selectionId != null)
    {
    DataList1.SelectedIndex = Int32.Parse(selectionId) - 1;
    }
    =======

    <asp:datalist id="DataList1" runat="server"
    SelectedItemStyle-BackColor="#66CC66">
    <SelectedItemTemplate>
    <asp:Label id="MyLabel" runat="server" CssClass="MenuSelected"
    Text="Test" />
    </SelectedItemTemplate>
    <ItemTemplate>
    <asp:HyperLink id="Hyperlink1" runat="server"
    CssClass="MenuUnselected" Text='<%# DataBinder.Eval(Container.DataItem,
    "Name")%>' NavigateUrl='<%# "articles.aspx?recordNo=" +
    DataBinder.Eval(Container.DataItem, "ID")%>' >
    </asp:HyperLink>
    </ItemTemplate>
    </asp:datalist>


    Thank you,

    Lubomir
    Lubomir, Feb 26, 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. Randy Vande Hei
    Replies:
    0
    Views:
    587
    Randy Vande Hei
    Aug 4, 2003
  2. Dirk Meusel
    Replies:
    1
    Views:
    2,998
    Dirk Meusel
    Aug 19, 2003
  3. Raymond Du
    Replies:
    1
    Views:
    462
    Johann MacDonagh
    Dec 5, 2004
  4. Randy Vande Hei

    datagrid within SelectedItemTemplate of another grid

    Randy Vande Hei, Aug 4, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    122
    Randy Vande Hei
    Aug 4, 2003
  5. Steve Klett

    <selectedItemTemplate>

    Steve Klett, Nov 17, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    189
    Steve Klett
    Nov 19, 2003
Loading...

Share This Page