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. insert a image button in asp.net grid

insert a image button in asp.net grid

Scheduled Pinned Locked Moved ASP.NET
csharpcssasp-nettutorialquestion
4 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.
  • M Offline
    M Offline
    maddyg
    wrote on last edited by
    #1

    I have a grid. The bind the grid with the data from a dataset. I then add a column. I have to insert an image button in this column of the grid. when i click this image it should open another window. I want to know how can i insert an image into each row of the column and how to add an OnClick event to it. I am using the InitializeRow event but i am unable to insert an image and on click handler to it. Please send me your suggestions.

    J 1 Reply Last reply
    0
    • M maddyg

      I have a grid. The bind the grid with the data from a dataset. I then add a column. I have to insert an image button in this column of the grid. when i click this image it should open another window. I want to know how can i insert an image into each row of the column and how to add an OnClick event to it. I am using the InitializeRow event but i am unable to insert an image and on click handler to it. Please send me your suggestions.

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

      just add a template column, and create an imagebutton in ItemTemplate. then, use ItemDataBound Event: protected void datagrid_ItemDataBound(object sender, DataGridItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType==ListItemType.AlternatingItem) { ImageButton imgBtn = (ImageButton)e.Item.FindControl("ImageButton1"); //do whatever you want } } Was it a cat I saw?

      M 1 Reply Last reply
      0
      • J junglerover77

        just add a template column, and create an imagebutton in ItemTemplate. then, use ItemDataBound Event: protected void datagrid_ItemDataBound(object sender, DataGridItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType==ListItemType.AlternatingItem) { ImageButton imgBtn = (ImageButton)e.Item.FindControl("ImageButton1"); //do whatever you want } } Was it a cat I saw?

        M Offline
        M Offline
        maddyg
        wrote on last edited by
        #3

        I am using an infragistics grid and i am unable to find the datagrideventargs. If i create a template column and then if i bind the grid with a dataset. Will the column be overwritten by the columns in the dataset. what is a cat?

        J 1 Reply Last reply
        0
        • M maddyg

          I am using an infragistics grid and i am unable to find the datagrideventargs. If i create a template column and then if i bind the grid with a dataset. Will the column be overwritten by the columns in the dataset. what is a cat?

          J Offline
          J Offline
          junglerover77
          wrote on last edited by
          #4

          Sorry, I don't know what "infragistics grid" is. No, to bind a dataset to a datagrid will never overwrite the existing columns of the datagrid. If you set the property "AutoGenerateColumns" to false, no columns will be created when you execute "DataBind()". ---------------------------------- Was it a cat I saw?

          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