Basically, I have a textbox where a user can enter an ID from a database. To make things easier, the user can popup a GridView using a ModalPopupExtender to display all the tables columns, and they can Select a row, which then closes the modalpopupextender and sets the textbox to the row’s ID column.
So far I have this:
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
string testing = GridView1.SelectedRow.Cells[1].Text.ToString();
((TextBox)dtlsInsert.FindControl("txtNom")).Text = GridView1.SelectedRow.Cells[1].Text.ToString();
}
The ‘testing’ string gets populated, but it doesn’t seem to populate the txtNom textbox. Also, how do I close the modalpopupextender programatically?
Thanks
If
GridView1(and probably its containerPaneland the associatedModalPopupExtender) resides in an UpdatePanel, buttxtNomdoes not,txtNomwill not be refreshed by partial postbacks triggered byGridView1.There are several ways to solve this problem:
If you can, put
txtNomandGridView1in the sameUpdatePanel.Put
txtNomin anotherUpdatePanelthat has its UpdateMode property set toAlways.Perform a full postback, by registering
GridView1as a PostBackTrigger in yourUpdatePanel.Concerning your second question, ModalPopupExtender exposes
Show()andHide()methods on the server side, as well as similarshow()andhide()methods on the client side.