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. Modifying gridview data on the fly?

Modifying gridview data on the fly?

Scheduled Pinned Locked Moved ASP.NET
databasetutorialquestion
2 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
    Goalie35
    wrote on last edited by
    #1

    I'm returning data from a sql query that populates a gridview however I want to modify what's displayed in 1 of the gridview columns based on whether or not a value returned in the sql query is null. Basically, if the value in a particular row of data is null, I want to return an imagebutton that says "Add". If the value is not null, I want to return an imagebutton that says "Edit". For example, something like this: if(SqlQuery.SqlRow(20).SqlColumn(4).Value = null) { gridView.gridRow(20).gridColumn(4).Value = ""; } else { gridView.gridRow(20).gridColumn(4).Value = ""; } Any idea how I can do this? Thanks. -goalie35

    J 1 Reply Last reply
    0
    • G Goalie35

      I'm returning data from a sql query that populates a gridview however I want to modify what's displayed in 1 of the gridview columns based on whether or not a value returned in the sql query is null. Basically, if the value in a particular row of data is null, I want to return an imagebutton that says "Add". If the value is not null, I want to return an imagebutton that says "Edit". For example, something like this: if(SqlQuery.SqlRow(20).SqlColumn(4).Value = null) { gridView.gridRow(20).gridColumn(4).Value = ""; } else { gridView.gridRow(20).gridColumn(4).Value = ""; } Any idea how I can do this? Thanks. -goalie35

      J Offline
      J Offline
      jcdevnet
      wrote on last edited by
      #2

      There are many ways you can handle this, one that comes to mind is On the column where you want to add this functionality 1.- Make that column a template column, this will allow you to Add controls to the column anyway you want 2.- add an Image Button on the column 3.- On the tag look for the source property of the image button 4.- Add something like this <asp:imageButton id=imgButton1 runat=server ImageSource="<%(Eval(Container.DataItem, 'Column'))'Add.jpg':'Edit.jpg'%>" /> About the property of the image I don't recall if it is Source or Image Source but you get the Idea

      Greets! Joel

      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