Change button text in RadListView when clicked with javascript

1 Answer 55 Views
Top achievements
Rank 1
Tom asked on 12 May 2021, 01:23 AM | edited on 12 May 2021, 01:26 AM

When a button in a RadListView is clicked, I want to change the text of the button on the client side.  I can find the listview and the index of the row, but can't set the button text of the clicked button.  The code below always changes the text of the button in the first record.

Also, is there an easier way to find the button without adding an attribute in radlistview1_ItemDataBound?

function updateBtn(sender, args) {
   var listview = $find('<%=radlistview1.ClientID%>');
   var myindex = sender._element.getAttribute("rowindex");
   var btn = $telerik.findControl(document.documentElement, "radbutton1");
   //How to select the button that was clicked?
   btn.set_text("Clicked"); //works for first row only

<telerik:RadListView runat="server" ID="radlistview1" DataSourceID="SqlDataSource1" DataKeyNames="myRecordid">
   <telerik:RadButton runat="server" ID="radbutton1" Text='button'
       ButtonType="StandardButton" RenderMode="Auto"
       OnClientClicked = "updateBtn"
       AutoPostBack="false" UseSubmitBehavior="false">


Private Sub radlistview1_ItemDataBound(sender As Object, e As RadListViewItemEventArgs) Handles radlistview1.ItemDataBound
   ' Add an attribute to the button that can be passed to JS 
   If TypeOf e.Item Is RadListViewDataItem Then
      Dim item As RadListViewDataItem = TryCast(e.Item, RadListViewDataItem)
      Dim btn As RadButton = TryCast(item.FindControl("radbutton1"), RadButton)
      btn.Attributes.Add("rowindex", item.DataItemIndex.ToString())
   End If
End Sub

1 Answer, 1 is accepted

Sort by
Attila Antal
Telerik team
answered on 14 May 2021, 12:59 PM | edited on 14 May 2021, 01:03 PM

Hi Tom,

If you want to change the Text of the Clicked button, the "sender" argument of the ClientClicked event is the button that is being clicked.


function updateBtn(sender, args) {
    var theClickedButton = sender;

    theClickedButton.set_text("New Text for this Button");

Check out the RadButton Client-side Programming article to learn more about available properties, methods, and events on Client-Side.


Update: There are other ways to get the item index, but doing that in the ItemDataBound event is the most accurate.


Attila Antal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at

Asked by
Top achievements
Rank 1
Answers by
Attila Antal
Telerik team
Share this question