This is a migrated thread and some comments may be shown as answers.

Gridview row index after filtering

2 Answers 383 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Keko
Top achievements
Rank 1
Keko asked on 15 Nov 2015, 10:50 PM

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 Answers, 1 is accepted

Sort by
0
Keko
Top achievements
Rank 1
answered on 16 Nov 2015, 11:08 AM

  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  

 

0
Dimitar
Telerik team
answered on 16 Nov 2015, 11:36 AM
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
Tags
GridView
Asked by
Keko
Top achievements
Rank 1
Answers by
Keko
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or