tags:

views:

301

answers:

1
+1  Q: 

Listview edit item

hello

I have trouble with editing listview (asp.net 3.5 server control). I want to accomplish following task. When click on edit button in my listview I want to open dialog window where I can edit user information. The dialog is standard jquery dialog.

Issue I have is when I click on edit button, the edit button fires postback. Is there a way that I can open my dialog without a postback but still to get my "CommandArgument" id through to dialog.

in my listview item template I have following

<asp:LinkButton CommandName="Edit" id="lbEditUser" CommandArgument='<%#Eval("id") %>' runat="server"  >Edit</asp:LinkButton>

and in my code behind

protected void lvUsers_OnItemCommand(object sender, ListViewCommandEventArgs e)
{

    if (String.Equals(e.CommandName, "Edit"))
    {
        var member = Member.GetMemberFromLoginName(lbEditUser.CommandArgument);
        // code 

    }

}
+1  A: 

You'll need to change your Edit button to call a client-side function that opens your jQuery window, and then returns false. Returning false will cancel the postback. You can pass in your command argument as a parameter to your clientside function, or alternately add it somewhere else on the page where you can access it with javascript.

Something like this:

    <asp:LinkButton CommandName="Edit" id="lbEditUser" 
OnClientClick='myJavascript(<%#Eval("id") %>); return false;' 
runat="server">Edit</asp:LinkButton>
womp

related questions