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

CurrentRow

3 Answers 72 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kuba
Top achievements
Rank 1
Kuba asked on 10 Sep 2013, 11:55 AM
I have a problem with getting CurrentRow Index.

private void myRadGridView_DefaultValuesNeeded(object sender, Telerik.WinControls.UI.GridViewRowEventArgs e)
{
      int index = e.Row.Index;
      int index2 = this.myRadGridView.CurrentRow.Index;
}

Both ways give me one result: -1
My GridView is bound with dataSet.
How can I get CurrentRow Index in DefalutValuesNeeded event?

Help for thanks.

Kuba

3 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 13 Sep 2013, 10:40 AM
Hello Kuba,

Thank you for contacting Telerik Support.

You can initialize the new row in RadGridView by handling the DefaultValuesNeeded event. This event fires after clicking the "add new row" link and before entering edit mode. It is normal to obtain index of the current row -1, because this new row is still not a part of the grid data because, you have not committed the new row yet. If you need to know on which index the new row will be probably inserted after pressing enter key, you may use:
private void radGridView1_DefaultValuesNeeded(object sender, GridViewRowEventArgs e)
{
    int index = e.Row.Index;
    int index2 = this.radGridView1.CurrentRow.Index;
 
    int futureNewRowIndex = this.radGridView1.Rows.Count;
}

I hope this information helps. Should you have further questions, I would be glad to help.

Regards,
Desislava
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Szymon
Top achievements
Rank 1
answered on 27 Sep 2013, 07:33 AM
Hi!
I have similar problem to Kuba, but my job is to read from new row not yet inserted to DataGrid. I need to open a new window, which depend on option which is chosen by user in GridView ComboBox, but I can't reach this chosen value. How can I obtain data from new row, while it's not yet part of the grid? 

Regards,
Szymon.
0
Szymon
Top achievements
Rank 1
answered on 01 Oct 2013, 08:20 AM
Problem solved. ;)
Tags
GridView
Asked by
Kuba
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Szymon
Top achievements
Rank 1
Share this question
or