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. DataGrid TemplateColumns help

DataGrid TemplateColumns help

Scheduled Pinned Locked Moved ASP.NET
help
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.
  • T Offline
    T Offline
    tonaxxl
    wrote on last edited by
    #1

    plz help i add image at templetcolumn but i wanna to change its url from row to row from the code thankx

    M 1 Reply Last reply
    0
    • T tonaxxl

      plz help i add image at templetcolumn but i wanna to change its url from row to row from the code thankx

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Hi there, If you want to change the ImageUrl property of an image object, you first need to get a reference to that image control with the help of the FindControl method, then you can set the ImageUrl property. The sample code looks something like this:

      private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
      {
      if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
      {
      //Here, I assume the image's id is 'imgID'
      Image imgControl = e.Item.FindControl("imgID") as Image;
      if(imgControl != null)
      {
      imgControl.ImageUrl = "Images/logo.gif";
      }
      }
      }

      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