473,320 Members | 1,948 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

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
1 2265
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Lauchlan M | last post by:
Hi In my aspx page HTML I have <a href='<%# DataBinder.Eval(Container.DataItem, "Name") %>'> <%# DataBinder.Eval(Container.DataItem, "Name") %> I am trying to create a hyperlink to...
2
by: Mark | last post by:
Hello Can anyone explain what the "#" does in a DataGrid template column like <%# DataBinder.Eval(Container, "DataItem.Phone") % I don't see anything about it in the MSDN help Thanks Mar
1
by: CJM | last post by:
I've copied (& modified) some code from MSDN which uses a Repeater control, but I'm getting an error: Unexpected end of file looking for </HeaderTemplate> As far as I can see I've not made an...
1
by: Ed West | last post by:
Am getting this error with the following code, particularly this line: <%# Check(DataBinder.Eval(Container.DataItem, "broker_id"))%> I am creating checkboxes and the Check function checks to...
0
by: info | last post by:
I have a datalist with ItemTemplate as a part of my control, however every time the ItemTemplate repeats, it inserts a <br>. How do I get it to not insert a <br>? I need it to be a DataList as...
5
by: ad | last post by:
I find there are some tag like <%= %> and <%# > in my .aspx file. What is the diffreence between <%= %> and <%# %>
4
by: Satya | last post by:
Hi all, The following code is throwing a run time error "The server tag is not well formed. " <ItemTemplate> <asp:HyperLink Runat="server" ID="lnkFile"...
3
by: webserverpete | last post by:
I would like to have multiple <td> in a repeater control. The below code does not work: <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1" DataMember="DefaultView">...
3
by: | last post by:
I have been researching articles on google on how to create a simple RSS feed that sucks <title><blurb><link><date> out of a sql server 2000 database via an aspx page. I know it has to be pushed...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.