How to pass data on a form using ModalPopupExtender with ASP.NET server code

Posted on 2009-04-29
Last Modified: 2013-12-17
I am trying to use a ModalPopupExtender to pop a form and edit a selected row in a grid view. Everything is in the same page but my information is not getting passed to the pop up. How can I pass this data to the form and what is the best event I can use to populate this form. I am not using java script and I wonder if this can be done with pure ASP.NET server code.

Question by:dpiteleconnect
    LVL 9

    Expert Comment

    Yes you can set the modalpopup fields on server-side. You can set row value into textboxes in edit button click event like

    See the full implementation from (needs registration to download source code)
    	protected void btnEditPerson_Click(object sender, EventArgs e) {
    		ImageButton btnEdit = sender as ImageButton;
    		GridViewRow row = (GridViewRow)btnEdit.NamingContainer;
    		hidPersonEditIndex.Value = Scrub(row.Cells[1].Text);
    		txtFirstName.Text = Scrub(row.Cells[2].Text);
    		txtLastName.Text = Scrub(row.Cells[3].Text);
    		txtMiddleName.Text = Scrub(row.Cells[4].Text);
    		Date1.Text = Scrub(((Label)row.Cells[5].Controls[1]).Text);

    Open in new window


    Author Comment

    I have tried that one and this one too, but still, it does not work. For some reason the text values do not show up when the pop up appears.

    When I debug the text porperty gets the value assigned but is gone when the form shows up.
    protected void gvUSOC_Patterns_RowCommand(object sender, GridViewCommandEventArgs e)
                if (e.CommandName == "Select")
                    string id = gvUSOC_Patterns.DataKeys[0].Value.ToString();
                    txtUSOC_Pattern_Id.Text = id;  

    Open in new window

    LVL 9

    Accepted Solution

    do you have your gridview wrapped in updatepanel?  does it help if you call updatepanel.update after setting your values like in the sample


    Author Closing Comment

    Yes , I over look the update panel and that was the solution. That is how I can render the new results. Cool , thanks tetorvik, you rock!!!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Suggested Solutions

    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    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

    8 Experts available now in Live!

    Get 1:1 Help Now