SelectedItemTemplate is ignored

L

Lubomir

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
 

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

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,006
Latest member
LauraSkx64

Latest Threads

Top