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

Discussion in 'ASP .Net' started by Ken Cox [Microsoft MVP], May 12, 2004.

  1. 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" <> wrote in message
    news:%...
    > 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
    >
    >
    >
     
    Ken Cox [Microsoft MVP], May 12, 2004
    #1
    1. Advertising

  2. Ken Cox [Microsoft MVP]

    Charlie@CBFC Guest

    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
     
    Charlie@CBFC, May 12, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lauchlan M
    Replies:
    1
    Views:
    7,278
    Lauchlan M
    Oct 15, 2003
  2. Tom Lee
    Replies:
    2
    Views:
    850
    Chris Carter
    Dec 9, 2003
  3. bg
    Replies:
    5
    Views:
    6,445
    Scott Allen
    Apr 16, 2004
  4. Eric Newton
    Replies:
    3
    Views:
    9,483
    Brock Allen
    Apr 4, 2005
  5. Joe Rattz
    Replies:
    2
    Views:
    611
    Robert Koritnik
    Sep 10, 2004
Loading...

Share This Page