Get SelectedIndex to Client-Side

2 posts, 0 answers
  1. Ayberk
    Ayberk avatar
    4 posts
    Member since:
    Jul 2010

    Posted 31 Mar 2011 Link to this post

    Greetings,

    How i can get SelectedItemIndex in listview to client-side?

    Regards,

  2. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 06 Apr 2011 Link to this post

    Hello Ayberk,

    There is no client property that indicates which elements are selected in the ListView. But you can easily transfer the selected items from server-side to client-side using a hidden field for example.

    C#:
    protected void RadListView1_PreRender(object sender, EventArgs e)
    {
        string selectedIndexes = "";
     
        if (RadListView1.SelectedIndexes.Count > 0)
            selectedIndexes = RadListView1.SelectedIndexes[0].ToString();
        for (int i = 1; i < RadListView1.SelectedIndexes.Count; i++)
        {
            selectedIndexes += ";" + RadListView1.SelectedIndexes[i];
        }
        RadListView1SelectedIndexes.Value = selectedIndexes;
    }
    JavaScript:
    var selectedIndexes = ($get("RadListView1SelectedIndexes").value).split(';') ;
     

    Greetings,
    Vasil
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top