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">
<ItemTemplate>
<telerik:RadButton runat="server" ID="radbutton1" Text='button'
ButtonType="StandardButton" RenderMode="Auto"
OnClientClicked = "updateBtn"
AutoPostBack="false" UseSubmitBehavior="false">
</telerik:RadButton>
</ItemTemplate>
</telerik:RadListView>
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