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. DATAGRID HELP!!!

DATAGRID HELP!!!

Scheduled Pinned Locked Moved C#
designhelpquestion
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.
  • D Offline
    D Offline
    dgap
    wrote on last edited by
    #1

    Hi all, Can anyone help me out with this: in my datagrid's ItemDataBound event, I want the method to do something like this: private void onItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { if (e.Item? or e.Item.Cells[0].Controls[0]??? == a CheckBox object) // then do stuff else // do nothing } any ideas?

    S 1 Reply Last reply
    0
    • D dgap

      Hi all, Can anyone help me out with this: in my datagrid's ItemDataBound event, I want the method to do something like this: private void onItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { if (e.Item? or e.Item.Cells[0].Controls[0]??? == a CheckBox object) // then do stuff else // do nothing } any ideas?

      S Offline
      S Offline
      SeMartens
      wrote on last edited by
      #2

      Hi, I think there are two possibilities to do that: 1) if(e.Item.Cells[0].Controls[0] is System.Web.UI.WebControls.CheckBox) { // do something } 2) if(e.Item.Cells[0].Controls[0].GetType().Equals(typeof(System.Web.UI.WebControls.CheckBox))) { // do something } I don't know if the first one is correct, I always use the second possibility. But be sure to test if there is a cell or control and that it is not null before you use the GetType() method (otherwise there will be a NullReferenceException). Regards Sebastian

      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