Link to home
Start Free TrialLog in
Avatar of dpiteleconnect
dpiteleconnect

asked on

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

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.

 
Avatar of tetorvik
tetorvik
Flag of Finland image

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 http://www.codeproject.com/KB/aspnet/GridView-ModalPopupExtend.aspx (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);
 
		updPerson.Update();
		mpePerson.Show();
	}

Open in new window

Avatar of dpiteleconnect
dpiteleconnect

ASKER

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;  
 
                ...
                
                ModalPopupExtenderUSOC_Pattern.Show();                
            }
        }             

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of tetorvik
tetorvik
Flag of Finland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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!!!