Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. how to control a data before show with repeater???

how to control a data before show with repeater???

Scheduled Pinned Locked Moved ASP.NET
helpdockertutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cool_man
    wrote on last edited by
    #1

    Hi all, I have a problem when show data in repeater control. I want to control data(ex: check is Null OR ="") before show in webpage like: Name: <%#Container.DataItem("Name")%> Email: <%#Container.DataItem("Email")%> When data in <%#Container.DataItem("Email")%> is Null(=""), it's show: Name: XYZ Email: I want to show like Name: XYZ Email: none Please help, thanks for any response.

    M B 2 Replies Last reply
    0
    • C cool_man

      Hi all, I have a problem when show data in repeater control. I want to control data(ex: check is Null OR ="") before show in webpage like: Name: <%#Container.DataItem("Name")%> Email: <%#Container.DataItem("Email")%> When data in <%#Container.DataItem("Email")%> is Null(=""), it's show: Name: XYZ Email: I want to show like Name: XYZ Email: none Please help, thanks for any response.

      M Offline
      M Offline
      Mike Ellison
      wrote on last edited by
      #2

      Hi. You could do it using a custom function in your databinding syntax. Something like:

      string FormatBlankAsNone(string sValue)
      {
          if (sValue == "") return "none"; else return sValue;
      }
      

      Name: <%#Container.DataItem("Name")%>
      Email: <%# FormatBlankAsNone(Container.DataItem("Email")) %>

      You probably need to modify this if DBNull is a legitamate value for your field, but the same idea should work.

      1 Reply Last reply
      0
      • C cool_man

        Hi all, I have a problem when show data in repeater control. I want to control data(ex: check is Null OR ="") before show in webpage like: Name: <%#Container.DataItem("Name")%> Email: <%#Container.DataItem("Email")%> When data in <%#Container.DataItem("Email")%> is Null(=""), it's show: Name: XYZ Email: I want to show like Name: XYZ Email: none Please help, thanks for any response.

        B Offline
        B Offline
        BammBamm
        wrote on last edited by
        #3

        You can use the onItemDataBound event in the codeBehind. Private Sub rptList_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptList.ItemDataBound If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then if DataBinder.Eval(e.Item.DataItem, "network").ToString.lenght > o then 'do something else ' do something else End If End If Hope that helps

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups