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. General Programming
  3. C#
  4. Change Buttonfield image dynamically

Change Buttonfield image dynamically

Scheduled Pinned Locked Moved C#
question
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.
  • A Offline
    A Offline
    Alagiri periyasamy merrillcorp com
    wrote on last edited by
    #1

    I have a gridview with a buttonfield, and I would like to change the image URL of the field based on a condition of one of the fields. How do I reference the buttonfield?

    P 1 Reply Last reply
    0
    • A Alagiri periyasamy merrillcorp com

      I have a gridview with a buttonfield, and I would like to change the image URL of the field based on a condition of one of the fields. How do I reference the buttonfield?

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      Please, start asking ASP.NET questions in the ASP.NET forum. There are so many grid views that have different behaviours depending on what the underlying technology, that it we could quite easily give you the wrong answer. Also, could you please change your user name? If you don't, you will end up being spammed. Now, as to your question (and please let this be the last ASP.NET one that you ask in this forum), how you change your button field really depends on how you want to trigger the field change. If it's just based on when you are binding the data to the GridView, there is a RowDataBound event that you can hook into when each row is bound to data. What you would do in this method is find the field you want (here's a crude method):

      private void CustomersGridView_RowDataBound(Object sender, GridViewRowEventArgs e)
      {
      if (e.Row.RowType == DataControlRowType.DataRow)
      {
      Button btnField = (Button)e.Row.FindControl("btnField");
      }
      }

      *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

      "Mind bleach! Send me mind bleach!" - Nagy Vilmos

      CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

      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