Note that there are some explanatory texts on larger screens.

plurals
  1. POGridview button Click - Populate user control, then open a Jquery dialog
    primarykey
    data
    text
    <p>I have a gridview of users. </p> <p>What I <em>WANT</em> to happen:</p> <p>When someone wants to edit a user's details, they click on the relevant gridview button, and a Jquery modal dialog opens up with the user information pre-populated.</p> <p>The Script:</p> <pre><code>$(document).ready(function () { //setup new User dialog $('#divEditUser').dialog({ autoOpen: false, draggable: true, width: 650, modal: true, title: "Edit User", open: function (type, data) { $(this).parent().appendTo("form"); } }); </code></pre> <p>Gridview:</p> <pre><code>&lt;asp:TemplateField ItemStyle-HorizontalAlign="Center"&gt; &lt;ItemTemplate&gt; &lt;asp:Button ID="btnEdit" CommandArgument='&lt;%# Eval("UserID") %&gt;' CommandName="EditUser" Text="Edit User" runat="server" UseSubmitBehavior="false"/&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; </code></pre> <p>The custom user control:</p> <pre><code>&lt;div id="divEditUser" title="Edit user"&gt; &lt;asp:HiddenField ID="hiddenUserID" runat="server" /&gt; &lt;cac:UserDetails runat="server" ID="UserDetails" /&gt; &lt;asp:Button id="btnSaveChanges" Text="Save Changes" runat="server" /&gt; &lt;/div&gt; </code></pre> <p>The Code Behind:</p> <pre><code>protected void gridUsers_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EditUser") { Button btn = (Button)e.CommandSource; // the button GridViewRow myRow = (GridViewRow)btn.Parent.Parent; // the row GridView myGrid = (GridView)sender; // the gridview string ID = myGrid.DataKeys[myRow.RowIndex].Value.ToString(); UserDetails.PopulateUser(Convert.ToInt16(ID)); THIS IS WHERE I WANT TO OPEN THE DIALOG } } </code></pre> <p>My problem is that the dialog box appears &amp; disappears on the postback, or it just won't display, or it will display on the popup (not populated) and again on the form (populated)</p> <p>I've tried <code>ScriptManager.RegisterStartupScript</code> </p> <p>I've also tried several <code>OnClientClick</code> methods. I've tried with update panels, without update panels</p> <p>but again &amp; again, no luck.</p> <p>Has anyone actually achieved this ? ...And would you share the code - please ?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload