Edit on row double-click in RadListView control

Thread is closed for posting
1 posts, 1 answers
  1. Answer
    Telerik Admin
    Telerik Admin avatar
    1572 posts
    Member since:
    Oct 2004

    Posted 13 May 2010 Link to this post


    RadControls version

    RadControls for ASP.NET AJAX 2010.1.415 and later
    .NET version

    NET 2.0 and later
    Visual Studio version

    2005 and later
    programming language

    browser support

    all browsers supported by RadControls

    The following project demonstrates how to switch a row in edit mode by double-clicking an arbitrary RadListView item and how to update this row when the user clicks another row in the RadListView.
    The example takes advantage of the editItem() client side function, to put the RadListView 's item in edit mode when the corresponding row is double clicked:
        <tr class="rlvI" ondblclick='row_doubleclick("<%#Container.DisplayIndex %>")'
                <asp:Label ID="ProductIDLabel" runat="server" Text='<%# Eval("ProductID") %>' /> 
    function row_doubleclick(index) 
         //set item into edit mode 
         $find("<%=RadListView1.ClientID %>").editItem(index); 

    Once the control is in edit mode, the user can enter data in the edit fields, and then after clicking another row, a user-friendly confirm dialog is displayed to prompt whether the update operation should be performed or not. This is achieved with the following code snippet:
    //hook the click event 
        if (!$(event.target).hasClass("rlvIEdit") && 
            if (editRowIndex > -1 && hasChanges) 
                hasChanges = false
                if (confirm("Update changes?")) 
                    $find("<%=RadListView1.ClientID %>").updateItem(editRowIndex); 
                editRowIndex = -1; 

    The value in editRowIndex variable is set in the code behind in the RadListView.PreRender event handler:
    protected void RadListView1_PreRender(object sender, EventArgs e) 
       ScriptManager.RegisterClientScriptBlock(thistypeof(Page), "editRowIndex",string.Format("var editRowIndex = {0};",  
          RadListView1.EditIndexes.Count > 0 ? RadListView1.EditIndexes[0] : -1), true); 

    NOTE: To convert the code snippet above to Visual Basic, please use our online C# to VB.Net converter tool here:  http://converter.telerik.com/

Back to Top

This Code Library is part of the product documentation and subject to the respective product license agreement.