DataList - accessing <tr>

  • Thread starter Thread starter Dunc
  • Start date Start date
D

Dunc

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>
 
Define an ItemTemplate and an AlternateItemTemplate. This allows you to have
every other item with a different format.
 
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
 

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

Back
Top