[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 672
  • Last Modified:

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.

 
0
dpiteleconnect
Asked:
dpiteleconnect
  • 2
  • 2
1 Solution
 
tetorvikCommented:
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

0
 
dpiteleconnectAuthor Commented:
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

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

updPerson.Update();
0
 
dpiteleconnectAuthor Commented:
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!!!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now