Applying formating to <%# DataBinder.Eval(Container.DataItem, "some_field")%> statements

  • Thread starter Ken Cox [Microsoft MVP]
  • Start date
K

Ken Cox [Microsoft MVP]

It might be simpler to pass lname and fname into a helper function that
would return the string in the format that you want. Here's the idea:

<asp:templatecolumn headertext="ProductID">
<itemtemplate>
<asp:Label runat="server" Text='<%#
fixit(DataBinder.Eval(Container, "DataItem.ProductID")) %>'>
</asp:label>
</itemtemplate>
</asp:templatecolumn>

Here's how my function looks in VB:

Public Function fixit _
(ByVal intID As Integer) As String
If intID = 10 Then
Return "message" & intID.ToString
Else
Return "message"
End If
 
C

Charlie@CBFC

Hi:

Is it possible to apply formatting to above statements which insert field
values into HTML when binding to a datasource using Repeater control? For
example, I would like to trim trailing spaces. Also, I have tried things
like this, but can't get them to work:

<%# DataBinder.Eval(Container.DataItem, "lname") +
((DataBinder.Eval(Container.DataItem, "some_field")=="")?"":", ") +
DataBinder.Eval(Container.DataItem, "fname")%>

I would like to apply a little logic to these statements to clean up
formatting. Can some one show me how or some examples?

Thanks,
Charlie
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top