Solved

Dynamically created controls in modal popup

Posted on 2010-08-31
10
310 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

867 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now