Access the TextBox that is in the Edit Template in List View

2 posts, 1 answers
  1. Kunal Bagga
    Kunal Bagga avatar
    26 posts
    Member since:
    Oct 2008

    Posted 13 Jan 2014 Link to this post

    I would like to know how to access the textbox element in Edit Template. 

    Consider I am having 2 Text Boxes and a Button in Edit Template. OnClick of the Button I have to get the text value from one textbox and have to do the some logic on the back end and would give result on the other Textbox. Here my problem is I couldn't access the element id of the TextBox in the back end. Even Page.FindControls("txtboxid") (during the edit mode)  returns a null and even I couldn't access the clientID of the control in the javascript as it returns a compilation error.

    I hope you understand my query and let me know what is the solution for this,
  2. Answer
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 13 Jan 2014 Link to this post


    Please have a look into the following C# code snippet to access the EditItemTemplate of RadListView in Button OnClick event.

    protected void RadButton1_Click(object sender, EventArgs e)
        foreach (RadListViewEditableItem item in RadListView1.EditItems)
            TextBox Text1 = item.FindControl("TextBox1") as TextBox; //accessing the first TextBox
            TextBox Text2 = item.FindControl("TextBox2") as TextBox; //accessing the second textbox
            //your condition
            Text2.Text = "Update"; // set the updated value to second TextBox

Back to Top