Solved

Dynamically created controls in modal popup

Posted on 2010-08-31
10
311 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Diagnostics with Net and Net.Sockets 2 29
Problem to refer to value 8 50
Please explain the parts of these 2 LINQ expressions 3 32
ASP.NET MVC -Add authentication 2 21
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
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…

803 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