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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Using conditional statements in datagrid?

Using conditional statements in datagrid?

Scheduled Pinned Locked Moved ASP.NET
csscomquestion
3 Posts 2 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.
  • G Offline
    G Offline
    gerryR com
    wrote on last edited by
    #1

    Hi All I'm trying to create a simple aspx page by pulling info from an existing excel sheet into a data grid. What I need to do is apply some conditions to this so that certain info is displayed depending on certain conditions. eg datagrid: name nickname URL link gerry http://gerry.com gerry william bill http://william.com bill What I need is if there's a value in nickname then the Text for the link will be that value, if not then it will be the name value. I've tried creating a template column but can see anywhere to put an if statement in there either. I'm new to all this and am not looking for someone to do this for me, just point me in the right direction as I want to understand why I'm doing what I'm doing. I appreciate any pointers anyone can give me. Rgds gerryR

    N 1 Reply Last reply
    0
    • G gerryR com

      Hi All I'm trying to create a simple aspx page by pulling info from an existing excel sheet into a data grid. What I need to do is apply some conditions to this so that certain info is displayed depending on certain conditions. eg datagrid: name nickname URL link gerry http://gerry.com gerry william bill http://william.com bill What I need is if there's a value in nickname then the Text for the link will be that value, if not then it will be the name value. I've tried creating a template column but can see anywhere to put an if statement in there either. I'm new to all this and am not looking for someone to do this for me, just point me in the right direction as I want to understand why I'm doing what I'm doing. I appreciate any pointers anyone can give me. Rgds gerryR

      N Offline
      N Offline
      NeverHeardOfMe
      wrote on last edited by
      #2

      There are two ways you can do this: Either in the ItemDataBound[^] event, or call a function[^] directly from your template column, passing the two values (name and nickname)

      G 1 Reply Last reply
      0
      • N NeverHeardOfMe

        There are two ways you can do this: Either in the ItemDataBound[^] event, or call a function[^] directly from your template column, passing the two values (name and nickname)

        G Offline
        G Offline
        gerryR com
        wrote on last edited by
        #3

        Thanks for that, Couldn't get my head around the databound method, I'll save that for another day. Got the function method working although I ran into another problem with that (null values), I'll post a seperate message about that. Thanks again gerryR

        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