Listview edit control

I'm having trouble editing listview (asp.net 3.5 server control). I want to complete the following task. When I click the edit button on my list, I want to open a dialog where I can edit the user information. The dialog is a standard jquery dialog.

The problem I have is when I click the edit button, the edit button triggers a postback. Is there a way that I can open my dialog without postback, but still get the "CommandArgument" id before the dialog.

in my listview item template i have the following

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

      

and in my code

protected void lvUsers_OnItemCommand(object sender, ListViewCommandEventArgs e)
{

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

    }

}

      

+2


source to share


1 answer


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

Something like that:



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

      

+1


source







All Articles