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. e.Item.FindControl and NullException

e.Item.FindControl and NullException

Scheduled Pinned Locked Moved ASP.NET
sysadmin
1 Posts 1 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.
  • C Offline
    C Offline
    CillyMe
    wrote on last edited by
    #1

    I've having trouble retrieving reference to a LinkButton in my DataGrid: option 1 option 2 option 3 Now, from code-behind, I am trying to reference the controls, then toggle "Enable" and "Visible" properties to ON/OFF depending on various conditions. I do that using FindControl(..), and the exception I got was NullException (ie. It can't find the control I specified.) I checked the "ID" of the controls, they're correct. Here's the code: public void Command(Object sender, DataGridCommandEventArgs e) { switch(e.CommandName) { case "ConfigureSecurity": ((LinkButton)e.Item.FindControl ("btnConfigSecurity")).Enabled=false; //NULL EXCEPTION HERE!! Just this ONE control (The one from which the "command" was raised originally!!) Perhaps there's more than ONE server control in the same . ((DropDownList) e.Item.FindControl("drpConfigAccessRights")).Enabled=true; //OKAY, FindControl succeeded in retrieving reference to this control. I can retrieve reference to "btnDownload" though - it's the first server control in ItemTemplate. ((LinkButton) e.Item.FindControl("btnSubmitSecurityConfig")).Enabled=true; //OKAY, FindControl succeeded in retrieving referen

    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