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. Visual Basic
  4. How to Handle the event raised by control inside the Template column of a DataGrid?

How to Handle the event raised by control inside the Template column of a DataGrid?

Scheduled Pinned Locked Moved Visual Basic
cssdatabasesysadminhelptutorial
3 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.
  • K Offline
    K Offline
    Krishnaraj Barvathaya B
    wrote on last edited by
    #1

    Hi all, In aspx file I have a Data grid. Of which two columns are Template columns. Both of these columns contain Label and Drop down list. On non-edit mode label will display the current information present in the DB. On clicking edit, it will change to Drop down list, giving option to make changes to that particular column value. Now list of items in the second template column drop down list must be populated on the basis of first column drop down box selection. Eg: first column lists countries then on selecting particular country, second column must display states which belong to the selected country. Also I have set the drop down list property AutoPostBack = True. So eah time when I change the country it sends it back o the server. But I am not getting any even handlers to handle the even triggered. Can anybody help me out? Thank in advance, Regards, Krishnaraj

    F 1 Reply Last reply
    0
    • K Krishnaraj Barvathaya B

      Hi all, In aspx file I have a Data grid. Of which two columns are Template columns. Both of these columns contain Label and Drop down list. On non-edit mode label will display the current information present in the DB. On clicking edit, it will change to Drop down list, giving option to make changes to that particular column value. Now list of items in the second template column drop down list must be populated on the basis of first column drop down box selection. Eg: first column lists countries then on selecting particular country, second column must display states which belong to the selected country. Also I have set the drop down list property AutoPostBack = True. So eah time when I change the country it sends it back o the server. But I am not getting any even handlers to handle the even triggered. Can anybody help me out? Thank in advance, Regards, Krishnaraj

      F Offline
      F Offline
      FrankyT
      wrote on last edited by
      #2

      ASP is not my specialty so I can't address the edit-mode or the postback, but for the events, the short answer is to: create a custom control that inheirts your first Template collumn. add a public delegate and event within it. raise the custom event on the first templatecollumns changed event. public delegate sub delIndexChanged(sender as object, e as system.eventargs) public event evtIndexChanged as delIndexChanged Private thing(sender as object, e as system.eventargs) handles me.selectedindexchanged RaiseEvent me.evtIndexChanged(sender,e) End sub in your mainpage (the one with the grid), Replace the template col reference with one to your custom control. once you instantiate the grid cols, add a handler for the evtIndexChanged that points to a sub with AddHandler MyGrid.cols(idx).evtIndexChanged , AddressOf where has the appropo parameter list for the delegate signature. that will fire whenever the first col changes. I would use it to gen a filterstatement for a dataview. to fire the col directly you can just RaiseEvent Object.Event(parameters...) I think. postbacks will complicate this. I just read somthing about the asp2.0 callback model, and they claim there are now ways to update stuff on the UI (via server side processing) without posting back on the client. you may want to look into it but as I said web isnt my area of expertise. Hope That Helps, FrankyT hey...slang is the vernacular for the vernacular...wow

      K 1 Reply Last reply
      0
      • F FrankyT

        ASP is not my specialty so I can't address the edit-mode or the postback, but for the events, the short answer is to: create a custom control that inheirts your first Template collumn. add a public delegate and event within it. raise the custom event on the first templatecollumns changed event. public delegate sub delIndexChanged(sender as object, e as system.eventargs) public event evtIndexChanged as delIndexChanged Private thing(sender as object, e as system.eventargs) handles me.selectedindexchanged RaiseEvent me.evtIndexChanged(sender,e) End sub in your mainpage (the one with the grid), Replace the template col reference with one to your custom control. once you instantiate the grid cols, add a handler for the evtIndexChanged that points to a sub with AddHandler MyGrid.cols(idx).evtIndexChanged , AddressOf where has the appropo parameter list for the delegate signature. that will fire whenever the first col changes. I would use it to gen a filterstatement for a dataview. to fire the col directly you can just RaiseEvent Object.Event(parameters...) I think. postbacks will complicate this. I just read somthing about the asp2.0 callback model, and they claim there are now ways to update stuff on the UI (via server side processing) without posting back on the client. you may want to look into it but as I said web isnt my area of expertise. Hope That Helps, FrankyT hey...slang is the vernacular for the vernacular...wow

        K Offline
        K Offline
        Krishnaraj Barvathaya B
        wrote on last edited by
        #3

        I have not tried the solution u have given. Coz most of the things u mentioned did not go into my mind. It may take some time to understand. But anyway thanks a lot for taking trouble to give me a solution. :) Regards, Krishnaraj

        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