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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Problem loading a user control dynamically into a gridview and the controls events not triggering

Problem loading a user control dynamically into a gridview and the controls events not triggering

Scheduled Pinned Locked Moved ASP.NET
helpcssdatabasewpfwcf
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
    DanChin
    wrote on last edited by
    #1

    I am developing a application which uses the update panel to refresh a gridview when changes are made in a dynamically loaded usercontrol which is loaded as one of the cells of the grid I am experiencing some strange issues firstly the grid is loading the control in the RowDataBound event and binding to the data in PageLoad this approach causes a problem when its time to update the data within the usercontrol due to the buttons event which updates the db fires after the PageLoad as you can determine the PageLoad will bind the grid to the db before the buttons update code as run so the changes will not get reflected. Now the problem arrises I put my data binding code as i would later on in the life cycle [onPreRender] so the button can update the db and changes will be rendered. but what happens is the buttons event handler in the control does not get triggered. but the async postback is taking place, the buttons click event works when the databinding code is in the Page_Load but but not this way in PreRender. i have had this problem for a couple of days now i dont know if its a issue with binding so late on in the cycle or related to the buttons events not getting registered. I would much appreciate any feedback or advice. Regards Dan.

    Dan

    C 1 Reply Last reply
    0
    • D DanChin

      I am developing a application which uses the update panel to refresh a gridview when changes are made in a dynamically loaded usercontrol which is loaded as one of the cells of the grid I am experiencing some strange issues firstly the grid is loading the control in the RowDataBound event and binding to the data in PageLoad this approach causes a problem when its time to update the data within the usercontrol due to the buttons event which updates the db fires after the PageLoad as you can determine the PageLoad will bind the grid to the db before the buttons update code as run so the changes will not get reflected. Now the problem arrises I put my data binding code as i would later on in the life cycle [onPreRender] so the button can update the db and changes will be rendered. but what happens is the buttons event handler in the control does not get triggered. but the async postback is taking place, the buttons click event works when the databinding code is in the Page_Load but but not this way in PreRender. i have had this problem for a couple of days now i dont know if its a issue with binding so late on in the cycle or related to the buttons events not getting registered. I would much appreciate any feedback or advice. Regards Dan.

      Dan

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      If you load a control during page load or later, then it won't exist early enough for viewstate to be restored, so no events will fire.

      Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      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