473,382 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Datalist CSS lagging

The basic scenario:

I have a tab control that is really just a Datalist which contains an ItemTemplate and SelectedItemTemplate. A LinkButton is contained in each of these templates with a CSS style applied to it (Selected and Unselected appropriately).

The control works BUT it lags behind by one selection. What I mean by this is that if index 0 is selected(set when the control is loaded), none of the items appear to be selected. If I then select index 2, in the SelectedIndexChanged event the index is actually 2 BUT the CSS class for 'selected' is assigned to the Linkbutton in index 0. If I then select index 3 on the control the selected index in the event IS 3 but the CSS gets applied to index 2 (the index I selected in the previous selection)

I am sure that I could just set the CSS class to all buttons to the 'unselected' CSS class and then programatically set the class for the selected index but this seems like a hack to me.

The markup for the Datalist is as follows:

<asp:DataList ID="dlTabControl" runat="server" CssClass="left" RepeatDirection="Horizontal" BorderWidth="0px">
<ItemTemplate>
<asp:LinkButton ID="btnName" CssClass="UnselectedTab" runat="server" CommandName="select" Text='<%# Eval("Name") %>' CommandArgument='<%# Eval("Value") %>' />
</ItemTemplate>
<SelectedItemTemplate>
<asp:LinkButton ID="btnName" CssClass="SelectedTab" runat="server" CommandName="select" Text='<%# Eval("Name") %>' CommandArgument='<%# Eval("Value") %>' />
</SelectedItemTemplate>
</asp:DataList>


Has anyone seen this before or have any idea how to correct it? My gut tells me that the SelectedItemTemplate should be applied to the selected index but for some reason it is lagging one step behind.
Mar 23 '07 #1
1 1777
Solution:

I found the solution to this problem. I had not rebound the data in the SelectedIndexChanged event because although the data was dynamic (the tabs could change depending on selections made earlier in the application), once the page had been loaded the data would remain the same (my tabs didn't change).

Apparently the data must still be rebound to get the templates to load in the correct order so even though the selectedindex of the datalist was showing the correct index this wasn't taking effect until the data was rebound.

I am still not exactly sure why this is the case, since the control did not loose the data it had been assigned previously (the tabs always maintained their values from the initial load) but it works so I am happy. =)

If anyone cares to enlighten me to why this makes a difference I am all ears (and will check back here a few more times for info).

-MT
Mar 23 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: pete K | last post by:
Is it possible in asp.net to have a datalist in the itemtemplate of another datalist? For example: <asp:datalist id="MyList" runat="server"> <ItemTemplate> <table border="0" width="300">...
10
by: Bharat | last post by:
Hi Folks, Suppose I have two link button on a page (say lnkBtn1 and lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically created control. And On the click event of the lnkBtn2 I...
4
by: Patrick.O.Ige | last post by:
I have a CheckBoxList in a DataList and i'm trying to get item Selected after doing a postBack. I have set my CheckBoxlist AutoPostBack="True" Any ideas what 'm doing wrong? It seems not to...
6
by: Paul | last post by:
I am trying to use a DataList and the ItemTemplate. I am binding the Datalist to a SQL query that gives me a list of Items with a Parent Category. I want to loop through all the items, but...
2
by: Hans Merkl | last post by:
Hi, I am trying to use a user control as EditItemTemplate in a DataList. It loads fine but I can't figure out how to bind to the data of the DataList. Here is what I have got so far: ...
3
by: Mirek Endys | last post by:
I have DataList as part of DataList item. DataList in DataList. The parent DataList working well including Edit command, that shows Edit template and correctly bind the data into edit template...
0
by: Les Caudle | last post by:
I have a menu system composed of a DataList nested inside a DataList. The outer DataList has it's DataSource (composed of a DataSet with two tables linked by a CategoryPagesRelation Relation) set...
1
by: AJ | last post by:
Hi all, With the following code in mind : <asp:DataList ID="dlOne" DataKeyField="myField1" DataSource="<%# GetDataSource1()" Runat="server"> <ItemTemplate> Output Value Here! <asp:DataList...
3
by: Crazy Cat | last post by:
Hi all, I am developing an asp.net 2.0 application in Visual Studio 2005. On my page I have a simple datalist that is bound programmatically to a collection of simple objects. On this page I...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.