Deselect dinamically Grid's items

4 posts, 0 answers
  1. Andrea D'Orio
    Andrea D'Orio avatar
    12 posts
    Member since:
    Mar 2007

    Posted 03 Mar 2009 Link to this post

    Hi,
    I need to deselect all items selected of a Grid from c# code (not javascript).
    i try to deselect through:

    for (int i = 0; i < RadGrid1.SelectedItems.Count; i++)
    {

       RadGrid1.SelectedItems[i]
    .Selected = false;
    }

    RadGrid1.Rebind();

    But deselect only a first row selected. Are there other way?

    Thanks in advance
    Andrea
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 03 Mar 2009 Link to this post

    Hello Andrea,

    You can loop through the selected items of the grid and deselect the items as shown below:
    cs:
     protected void Button1_Click(object sender, EventArgs e) 
        { 
            foreach (GridDataItem dataItem in RadGrid1.SelectedItems) 
            { 
                dataItem.Selected = false
            } 
        } 

    Thanks
    Princy.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 03 Mar 2009 Link to this post

    Hello Andrea,

    Yet another possible approach:
    protected void Button1_Click(object sender, EventArgs e) 
        RadGrid1.SelectedIndexes.Clear(); 

    Regards,
    Daniel
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Andrea D'Orio
    Andrea D'Orio avatar
    12 posts
    Member since:
    Mar 2007

    Posted 03 Mar 2009 Link to this post

    Thanks! Works in both case

    Andrea
Back to Top