Results 1 to 5 of 5

Thread: Do NOT understand the FORMAT member

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216

    Question Do NOT understand the FORMAT member

    ok I have data correctly loading into a datalist but I want to set the maximum length that can be displayed to 20 chars. How can I do that. I am calling the DataBind method in the code behind. I tried the 3rd param but it did nothing.

    Thanks
    Code:
    <%# DataBinder.Eval(Container.DataItem, "AnnouncementTitle", "{0:5}") %>

  2. #2
    Lively Member
    Join Date
    Jan 2001
    Location
    Worcester, MA
    Posts
    77
    you can use a left(data,20) in your select statement.

    Code:
    strSQL="select left(title,20) from movies order by title"
    "Find all you need in your mind if you take the time" -DT

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216
    yep! Sometimes we don't see the forest for the trees

  4. #4
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    For more complex conversions, you can also create a function that will change the data....

    This will call the FormatTheData function:

    <%# FormatTheData(DataBinder.Eval(Container.DataItem, "AnnouncementTitle")) %>

    The function:

    Public Function FormatTheData(title As string) As string
    'Do all your conversions to the title variable here, then
    ' return the converted title as a string.
    End Function

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216
    Originally posted by hellswraith
    For more complex conversions, you can also create a function that will change the data....

    This will call the FormatTheData function:

    <%# FormatTheData(DataBinder.Eval(Container.DataItem, "AnnouncementTitle")) %>

    The function:

    Public Function FormatTheData(title As string) As string
    'Do all your conversions to the title variable here, then
    ' return the converted title as a string.
    End Function
    Yes but for me that is the most undesirable...thanks though

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width