Listview edit item

listview

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 

    }

}

Best Answer

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>