Gridview row index after filtering

3 posts, 0 answers
  1. Keko
    Keko avatar
    2 posts
    Member since:
    Sep 2011

    Posted 15 Nov 2015 Link to this post

    Hi guys. 

    Got some problems with the radgridview. I have a radgridview with some filters. If user filters the data i need to get row index for some updates. But for me row index is always -1 after filtering. Without filtering code works well.

      private void grdDetay_CellEndEdit(object sender, GridViewCellEventArgs e)
            {

                var listId = 0;
                var dtyid = 0;
               
                GridViewRowInfo row = this.grdDetay.CurrentRow;
                int rowIndex = row.Index;
                listId = Convert.ToInt32(grdDetay.ChildRows[rowIndex].Cells[0].Value);
                dtyid = Convert.ToInt32(grdDetay.ChildRows[rowIndex].Cells[1].Value);
                
           }
                    ​

  2. Keko
    Keko avatar
    2 posts
    Member since:
    Sep 2011

    Posted 16 Nov 2015 in reply to Keko Link to this post

      private void grdDetay_CellEndEdit(object sender, GridViewCellEventArgs e)
            {
    varlistId = 0;
    vardtyid = 0;

    GridViewRowInfo row = this.grdDetay.CurrentRow;
                int rowIndex = row.Index;
    listId = Convert.ToInt32(grdDetay.ChildRows[rowIndex].Cells[0].Value);
    dtyid = Convert.ToInt32(grdDetay.ChildRows[rowIndex].Cells[1].Value);

           }

    How i can get listId ? or any other cell value at the edited row  

     

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 16 Nov 2015 Link to this post

    Hi Can,

    Thank you for writing.

    When the user is filtering, the filter row is current and this is why the index is -1. You can check if the user is editing data row with the following code:
    void radGridView1_CellEndEdit(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
    {
        if (radGridView1.CurrentRow != null && radGridView1.CurrentRow is GridViewDataRowInfo)
        {
            string value = radGridView1.CurrentRow.Cells[2].Value.ToString();
        }
    }

    Please let me know if there is something else I can help you with. 

    Regards,
    Dimitar
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top