Problem Using Data Binding Tags

  • Thread starter Thread starter Wayne Wengert
  • Start date Start date
W

Wayne Wengert

I am trying to modify the output of a repeater control based on values in
the source database. If I simply want to display the contents of a specific
field I use a syntax such as:

<td><%# Container.DataItem("Author") %></td>

This works fine but when I want to use a bound value in program logic I get
"Expression Expected" and/or other errors. I am trying code similar to the
following:

<%
If (<%#Container.DataItem("StartDate")%> > lastdate) then
lastdate = <%#Container.DataItem("StartDate") %>
Response.Write("<tr><td colspan='4'><h3>" & lastdate &
"</h3></td></tr>")
End If
Dim strTemp As String
strTemp = <%#Container.DataItem("StartDate")%>.ToString( "d" )
Response.Write("<td>" & strTemp & "</td>")
%>

I've tried eliminating the <% and %> in the binding tag since it is already
within a code block but that also fails.

What is the correct way to code this?

Wayne
 
Wayne,

There may be a way to do what you are trying to do. To be honest I think I would tell you to loop through the datatable and change the values there. I get the impression you are a ASP developer moving to .Net. Try using the .Net Controls like a DataList you may find some use in that.

-Calvin Luttrell
ProjectThunder.com
 
Calvin;

You are correct. I have been using classic ASP/VB/ADO and the transition to
..NET is not easy! I am trying to find samples via google searches and books
but finding practical solutions is not easy. Many of the examples I see are
"way over the top" with what seems to be overly complex solutions.

Wayne

message Wayne,

There may be a way to do what you are trying to do. To be honest I think I
would tell you to loop through the datatable and change the values there. I
get the impression you are a ASP developer moving to .Net. Try using the
..Net Controls like a DataList you may find some use in that.

-Calvin Luttrell
ProjectThunder.com
 
Back
Top