Container.DataItem

  • Thread starter Thread starter Mike P
  • Start date Start date
M

Mike P

I'm having trouble with C# syntax for Container.DataItem. This is the
VB version. CAn anybody help me out with the syntax?

<asp:DataList runat="server" id="dlResults"
Font-Name="Verdana" Font-Size="10pt">

<ItemTemplate>
<span style="font-size:15pt;font-weight:bold;">
<%# Container.DataItem.title %>
</span><br />
<%# Container.DataItem.snippet %><br />
[<a href="<%# Container.DataItem.URL %>"><%#
Container.DataItem.URL %></a>]
</ItemTemplate>

<SeparatorTemplate>
<p> </p>
</SeparatorTemplate>

</asp:DataList>

Any help would be really appreciated.


Cheers,

Mike
 
HI Mike,

What is the type of the bounded collection?

Container.DataItem is an object for the instance being bounded, if it's a
datatable for example you could do like this
((DataRow)Container.DataItem)["ColumnName"]

or if it's a strong typed collection of some type you could do like this
((CollectionType)Container.DataItem).Property

hoe this help,
 
Back
Top