Solved

Dynamically created controls in modal popup

Posted on 2010-08-31
10
304 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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 video discusses moving either the default database or any database to a new volume.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 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

17 Experts available now in Live!

Get 1:1 Help Now