By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,938 Members | 1,555 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,938 IT Pros & Developers. It's quick & easy.

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

P: n/a
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

Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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

"Charlie@CBFC" <ch*****@comcast.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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


Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.