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