Solved

Dynamically created controls in modal popup

Posted on 2010-08-31
10
312 Views
Last Modified: 2012-05-10
Dear experts,

I have a GridView where the user can select multiple rows. I need by pressing a button to show a modal popup that would contain as many groups of dynamically generated controls, as many records were selected in the GridView. E.g. if three records are selected, the popup would contain

checkBox1  textBox1  button1
checkBox2  textBox2  button2
checkBox3  textBox3  button3

The data in the controls would be taken from the GridView. If the user presses Submit button on the modal popup, I need to be able to handle the button press and retrieve the the data the user enters in checkboxes and textboxes of the modal popup.

P.S. I know how to show the modal popup, I just need to know how to dynamically create controls in the popup. Also, I realize that it would be easier to use a GridView within modal popup, but because of some reason unknown to me, when I handle the popup submit, the GridView contains no records. If somebody could help me with this, it would be even better than dynamically generated controls.

Thanks.
0
Comment
Question by:tantormedia
  • 5
  • 5
10 Comments
 
LVL 16

Expert Comment

by:SriVaddadi
ID: 33566563
I m wondering if want to show the modal pop-up with gridview/dynamic controls for editing purpose or for any other reason.

0
 

Author Comment

by:tantormedia
ID: 33566576
Yes, the user should be able to enter data into the controls, and that data should be accessible in the submit button press handler.
0
 
LVL 16

Expert Comment

by:SriVaddadi
ID: 33566644
Well, in that case why do you need another pop up window. Why not allow the user to edit the data in the same grid view and submit his changes?Check these links on how to implement editing in gridview http://dotnetdiscussion.net/2007/09/26/aspnet-gridview-updateeditcancel-hyperlinkfields-and-datakey-retrieval/http://msdn.microsoft.com/en-us/library/ms972948.aspx
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:tantormedia
ID: 33566665
Because it is not necessary just editing values in the GridView. E.g. it may be deleting a record when a new record is added to the Cancel table that would contain the cancellation reason entered by the user in a textbox.
0
 
LVL 16

Expert Comment

by:SriVaddadi
ID: 33566711
You could implement the delete operation using the ButtonColumn right?  Am i getting something wrong?
0
 
LVL 16

Expert Comment

by:SriVaddadi
ID: 33566719
0
 

Author Comment

by:tantormedia
ID: 33566744
So isn't it possible to do what I intended? Because my manager doesn't want extra buttons.
0
 
LVL 16

Accepted Solution

by:
SriVaddadi earned 500 total points
ID: 33566801
tantormedia, it is ofcourse possible to do what u r intending to but I m trying to understand what functionality you are trying to achieve and suggest you the best method. I guess you got me wrong. Delete button column is another column in the grid view which displays a small delete icon and when user clicks on it it deletes the record.I m sure user would prefer to do in place editing rather than in another popup.  If you still want to take your approach Adding dynamic controlshttp://msdn.microsoft.com/en-us/library/kyt0fzt1.aspx
0
 

Author Comment

by:tantormedia
ID: 33569409
Thank you SriVaddadi,

I applied what I found at that web site, and could display my controls. I also recreate them in button submit handler. But when I access the controls in the handler, the data entered by the user is gone. And the initial data set after creation of the controls is gone, too. Maybe it is because of the same reason that my GridView didn't preserve its rows. Could you please shed any light on how I can fix that?
Thanks.
0
 

Author Comment

by:tantormedia
ID: 33595577
Figured it out. The controls should be recreated in Page_Init(), i.e. before the ViewState is loaded.
Thanks.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question