This is a migrated thread and some comments may be shown as answers.

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

1 Answer 274 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Kunal Bagga
Top achievements
Rank 1
Kunal Bagga asked on 13 Jan 2014, 07:54 AM
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,

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 13 Jan 2014, 09:15 AM
Hi,

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

C#:
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
    }
}

Thanks,
Princy.
Tags
ListView
Asked by
Kunal Bagga
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or