473,406 Members | 2,956 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,406 software developers and data experts.

DataList - accessing <tr>

I have a data list control with 3 columns. I want every second *row* to
have a dfferent CSS class. Can someone tell me how to access the parent
tablerow, and add a cssclass? I'm guessing I'll need to put some code in
the itemcreated or itemdatabound?

Thanks in advance,

Duncan

---/ snip /---

<asp:datalist id="dlRegionList" runat="server" repeatcolumns=3
cssclass="tbl" width="100%">
<itemtemplate>
<a href="search.asp?area=<%# DataBinder.Eval(Container.DataItem,
"Regions_ID") %>">
<%# DataBinder.Eval(Container.DataItem, "RegionName") %>
</a>
</itemtemplate>

<alternatingitemtemplate>
<!-- this needs to have: tr class="tbl_2row" -->
<a href="search.asp?area=<%# DataBinder.Eval(Container.DataItem,
"Regions_ID") %">
<%# DataBinder.Eval(Container.DataItem, "RegionName") %>
</a>
</alternatingitemtemplate>
</asp:datalist>

Nov 17 '05 #1
3 3682
Define an ItemTemplate and an AlternateItemTemplate. This allows you to have
every other item with a different format.

"Dunc" <du**@ntpcl.f9.co.uk> wrote in message
news:eC****************@TK2MSFTNGP09.phx.gbl...
I have a data list control with 3 columns. I want every second *row* to
have a dfferent CSS class. Can someone tell me how to access the parent
tablerow, and add a cssclass? I'm guessing I'll need to put some code in
the itemcreated or itemdatabound?

Thanks in advance,

Duncan

---/ snip /---

<asp:datalist id="dlRegionList" runat="server" repeatcolumns=3
cssclass="tbl" width="100%">
<itemtemplate>
<a href="search.asp?area=<%# DataBinder.Eval(Container.DataItem,
"Regions_ID") %>">
<%# DataBinder.Eval(Container.DataItem, "RegionName") %>
</a>
</itemtemplate>

<alternatingitemtemplate>
<!-- this needs to have: tr class="tbl_2row" -->
<a href="search.asp?area=<%# DataBinder.Eval(Container.DataItem,
"Regions_ID") %">
<%# DataBinder.Eval(Container.DataItem, "RegionName") %>
</a>
</alternatingitemtemplate>
</asp:datalist>

Nov 17 '05 #2
Marina,

Thanks for your reply. At the bottom of the post, I'd included the code -
including an itemtemplate and alternateitemtemplate; this doesn't work, as
we're effectively trying to style the whole parent row, not a single item.

Any thoughts?

D

"Marina" <so*****@nospam.com> wrote in message
news:O0****************@TK2MSFTNGP15.phx.gbl...
Define an ItemTemplate and an AlternateItemTemplate. This allows you to
have every other item with a different format.

"Dunc" <du**@ntpcl.f9.co.uk> wrote in message
news:eC****************@TK2MSFTNGP09.phx.gbl...
I have a data list control with 3 columns. I want every second *row* to
have a dfferent CSS class. Can someone tell me how to access the parent
tablerow, and add a cssclass? I'm guessing I'll need to put some code in
the itemcreated or itemdatabound?

Thanks in advance,

Duncan

---/ snip /---

<asp:datalist id="dlRegionList" runat="server" repeatcolumns=3
cssclass="tbl" width="100%">
<itemtemplate>
<a href="search.asp?area=<%# DataBinder.Eval(Container.DataItem,
"Regions_ID") %>">
<%# DataBinder.Eval(Container.DataItem, "RegionName") %>
</a>
</itemtemplate>

<alternatingitemtemplate>
<!-- this needs to have: tr class="tbl_2row" -->
<a href="search.asp?area=<%# DataBinder.Eval(Container.DataItem,
"Regions_ID") %">
<%# DataBinder.Eval(Container.DataItem, "RegionName") %>
</a>
</alternatingitemtemplate>
</asp:datalist>


Nov 17 '05 #3
Try putting everything in each template into a div, with the appropriate
css class.
"Dunc" <du**@ntpcl.f9.co.uk> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
Marina,

Thanks for your reply. At the bottom of the post, I'd included the code -
including an itemtemplate and alternateitemtemplate; this doesn't work, as
we're effectively trying to style the whole parent row, not a single item.

Any thoughts?

D

"Marina" <so*****@nospam.com> wrote in message
news:O0****************@TK2MSFTNGP15.phx.gbl...
Define an ItemTemplate and an AlternateItemTemplate. This allows you to
have every other item with a different format.

"Dunc" <du**@ntpcl.f9.co.uk> wrote in message
news:eC****************@TK2MSFTNGP09.phx.gbl...
I have a data list control with 3 columns. I want every second *row* to
have a dfferent CSS class. Can someone tell me how to access the parent
tablerow, and add a cssclass? I'm guessing I'll need to put some code in
the itemcreated or itemdatabound?

Thanks in advance,

Duncan

---/ snip /---

<asp:datalist id="dlRegionList" runat="server" repeatcolumns=3
cssclass="tbl" width="100%">
<itemtemplate>
<a href="search.asp?area=<%# DataBinder.Eval(Container.DataItem,
"Regions_ID") %>">
<%# DataBinder.Eval(Container.DataItem, "RegionName") %>
</a>
</itemtemplate>

<alternatingitemtemplate>
<!-- this needs to have: tr class="tbl_2row" -->
<a href="search.asp?area=<%# DataBinder.Eval(Container.DataItem,
"Regions_ID") %">
<%# DataBinder.Eval(Container.DataItem, "RegionName") %>
</a>
</alternatingitemtemplate>
</asp:datalist>



Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John Geddes | last post by:
In both IE6 and Netscape 7: insertRow method of tbody is behaving as expected: - inserts a new row - increases tbody.rows.length BUT deleteRow is not doing the opposite. It DOES delete the...
7
by: F. Da Costa | last post by:
Hi, I' looking to retrieve ProdName1 form the <tr> below. <tr id="1-1-1" class="even"> <td> <div class="tier4"> <a href="#" class="leaf"></a> ProdName1 </div>
4
by: El Diablo | last post by:
Hi there, I'm trying dynamically generate extra rows in a table. So far this achieves this task within the tHead segment: theTable.tHead.appendChild(document.createElement('TR')) ....but...
3
by: Christopher Benson-Manica | last post by:
I have an HTMLInputElement in a <td>. I want to access all the <td>'s in the same row as the input element. var tr=theInputElement.parentNode.parentNode; Why isn't the input element's...
1
by: prefersgolfing | last post by:
I'm not using Master Pages, yet I'd like to display the contents of an HTML page within a <table><tr><td> on a .aspx. I have a lengthy guide already paginated in html. I'd like to embed the...
2
by: petereffect | last post by:
i have foll. code <tr> <a href="a1.shtml"> <td width='100%'> &nbsp;"+Testing+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td> </a>
5
by: mahesr | last post by:
I want to match some particular text between <tr>and </tr> or <td>and </td>.... in PHP. like below............ <table><tr> CATEGORY: <td><font face="Verdana" size="1" color="#A000A0"> Wedding...
3
by: jack | last post by:
Hi all im Creating a report in HTML with the help of dotnet.. im creating a which shows a data of 12 months .. the forst row of the column contains month names.. and the following data.. The...
7
by: Xiaoyan | last post by:
Hi,everyone: I have a problem now. I can't get the information between the <tr><td> and </td></tr>. for example: I use this regular expression can't get it, I don't know why....
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.