Access ClientDataKeyValue on button click

2 posts, 1 answers
  1. Chetan
    Chetan avatar
    13 posts
    Member since:
    Sep 2012

    Posted 30 Dec 2013 Link to this post

    I have a radbutton in ItemTemplate of RadListView. I have defined  ClientDataKeyNames="ID" 
    Now how do I get the  ClientDataKeyValue "ID" onClientClicked of radbutton? Is it possible to get the index of the ListviewITem on clientside javascript

    Thanks in advance.
  2. Answer
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 30 Dec 2013 Link to this post

    Hi Chetan,

    Please try the following code snippet get the ClientDataKeyValues of a RadListView on RabButton OnClientClicked event.

    <telerik:RadListView ID="RadListView1" Width="97%" AllowPaging="True" runat="server"
        AllowSorting="true" DataSourceID="SqlDataSource1" ItemPlaceholderID="ProductsHolder"
        DataKeyNames="ProductID" ClientDataKeyNames="ProductID" OnItemDataBound="RadListView1_ItemDataBound">
            <fieldset style="max-width: 920px;" id="FieldSet1">
                <asp:Panel ID="ProductsHolder" runat="server" />
            <telerik:RadButton ID="RadButton1" runat="server" Text="Demo" OnClientClicked="OnClientClicked1">

    protected void RadListView1_ItemDataBound(object sender, Telerik.Web.UI.RadListViewItemEventArgs e)
        if (e.Item is RadListViewDataItem)
            RadListViewDataItem item = e.Item as RadListViewDataItem;
            RadButton btn = item.FindControl("RadButton1") as RadButton;
            btn.Attributes.Add("rowindex", item.DataItemIndex.ToString());

    <script type="text/javascript">
        function OnClientClicked1(sender, args) {
            var listview = $find("<%=RadListView1.ClientID %>");
            var index = sender._element.getAttribute("rowindex");

    Hope this will helps you.
Back to Top