Solved

Dynamically created controls in modal popup

Posted on 2010-08-31
10
315 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

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…
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…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

705 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