Click here to Skip to main content
15,860,972 members
Articles / Web Development / ASP.NET

GridView with a single ModalPopupExtender/Panel for row editing

Rate me:
Please Sign up or sign in to vote.
4.93/5 (45 votes)
22 Feb 2007CPOL3 min read 299.2K   11.5K   149   57
GridView with a single ModalPopupExtender/Panel for row editing.
A gridview

Screenshot - persongrid.jpg

The modal

Screenshot - personGridEditWindow.jpg

Introduction

I am not a huge fan of inline row editing that is provided with most ASP.NET grids. So, recently I went about trying to implement a pop up edit window for editing the values contained within a grid's row. To make it even more interesting, I wanted it use Asynchronous JavaScript callbacks to do this. Since I was already using Ajax.net and the AJAX Toolkit, I went about trying to figure out which control to use, and if any, what they provided would suit me.

Requirements

  1. I wanted to be able to pop up an edit window for editing that disabled the background window (or gave the appearance of being disabled).
  2. I wanted to control the save and edit server-side as I was using custom business objects that were bound to the grids through the ObjectDataSource control.
  3. It needed to be asynchronous. I wanted functionality, but I wanted speed, and ease for the customer as well.

History

The ModalPopup: I first looked at the modal popup extender as it seemed to be exactly what I needed. However, there were a couple issues with how I wanted to use it.

  1. The TargetControlID property is required. So, if I wanted to use it the way it was designed, then I would have to embed a ModalPopup into a ItemTemplate column in the grid with an associated button. This did not appeal to me at all. The same issue occurs for the PopupControlID.
  2. Getting the values into the fields contained in the pop-up panel. Again, I could have embedded the panel into the ItemTemplate column and bound the fields using standard binding. This really did not appeal to me. HTML bloat anyone?

The PopupControl: I quickly abandoned this one, as it had even more issues than the modal popup for what I was trying to do.

Raj Kaimal - Master Details using AJAX and the UpdatePanelPopupExtender: I have to say this one looked awesome, and ran quite well. The only issue I ran into is that it flaked out sometimes when doing custom data binding. The other issue was support. I would have hated to wait on Raj to have to update his code for the next version of AJAX. Considering their track record so far with breaking changes to the design of Ajax.net from the beta's to 1.0, I was not overly enthusiastic about this prospect. Nicely done control though. Would love to see something similar embedded into Ajax.net so the workaround I found would be obsolete.

Frustrated, I was about to give up when I read Dynamically-Created-ModalPopupExtender. Which led me back to the use of the ModalPopupExtender. All of the example code is included in the zip, along with an example showing multiple grids embedded inside an ASP.NET AJAX tab. You will need VS.NET 2005 and version 1.0 of the ASP.NET AJAX framework. The images are courtesy of Michael Hoskins.

Changes:

  • 02/26/2007 - Added an option to use XML as the data source. Will default to XML. Also added an email grid.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionVB equivlant of this ModalPopupExtender/Panel ?? Anyone? Pin
Chenga888815-Jul-13 6:34
Chenga888815-Jul-13 6:34 
GeneralMy vote of 5 Pin
MohamedKamalPharm27-Jun-13 12:12
MohamedKamalPharm27-Jun-13 12:12 
GeneralMy vote of 5 Pin
Manoj Kumar Choubey7-Feb-12 21:45
professionalManoj Kumar Choubey7-Feb-12 21:45 
GeneralWork like a charm -- Modifications Pin
nitin_rajwar16-Mar-10 1:53
nitin_rajwar16-Mar-10 1:53 
GeneralRe: Work like a charm -- Modifications Pin
nitin_rajwar16-Mar-10 22:14
nitin_rajwar16-Mar-10 22:14 
GeneralIs it Possible to access Multiple Modal popupextender to single panel Pin
ravinandhini28-Jan-10 20:21
ravinandhini28-Jan-10 20:21 
Generalwant to delete the background shaded region Pin
Ashok Nalam25-Feb-09 18:21
Ashok Nalam25-Feb-09 18:21 
Nice article ... when a modal popup shows in the background of popup we are getting a shaded region with some gray color how can we remove this bakc ground shared region and diplay like general javascript popup.

Ashok Nalam

GeneralWorks Beautifully!!! Pin
nrps20-Feb-09 19:03
nrps20-Feb-09 19:03 
GeneralPage Refreshes on GridView Button Click Pin
_Groker21-Jan-09 9:39
_Groker21-Jan-09 9:39 
QuestionWhat is SCRUB? Pin
denniswong28828-Aug-08 15:14
denniswong28828-Aug-08 15:14 
AnswerRe: What is SCRUB? Pin
klyoung28-Jun-13 6:45
klyoung28-Jun-13 6:45 
GeneralVery Helpful Pin
ryanoc33319-Aug-08 10:44
ryanoc33319-Aug-08 10:44 
Newsquestion plz help on grid view problem Pin
vardhanmm@gmail.com1-May-08 23:31
vardhanmm@gmail.com1-May-08 23:31 
Generalexcellent article Pin
msoul219-Nov-07 16:50
msoul219-Nov-07 16:50 
QuestionThe answer must be so close... Pin
AndoTheOptimal22-Oct-07 5:24
AndoTheOptimal22-Oct-07 5:24 
GeneralProblem using the technique with formview Pin
mhariri13-Oct-07 3:14
mhariri13-Oct-07 3:14 
AnswerRe: Problem using the technique with formview Pin
Henrique Duarte9-Nov-07 1:02
Henrique Duarte9-Nov-07 1:02 
GeneralMuch Thanks Pin
airjasper20-Sep-07 14:06
airjasper20-Sep-07 14:06 
QuestionAppreciation and Question Pin
details@insidespirit.com17-Aug-07 7:55
details@insidespirit.com17-Aug-07 7:55 
Questionsticky panel Pin
dsmportal14-Aug-07 4:13
dsmportal14-Aug-07 4:13 
QuestionQuestion Pin
stormcandi11-Jun-07 9:09
stormcandi11-Jun-07 9:09 
AnswerRe: Question Pin
Torben716-Jul-07 2:13
Torben716-Jul-07 2:13 
GeneralRe: Question Pin
stormcandi6-Jul-07 5:35
stormcandi6-Jul-07 5:35 
Questiona problem! Pin
vicqqq5-Jun-07 16:46
vicqqq5-Jun-07 16:46 
QuestionPaging do not work Pin
kcchenkd29-Apr-07 17:33
kcchenkd29-Apr-07 17:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.