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

Selected Rows and Columns

2 Answers 172 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Oscar Zapata
Top achievements
Rank 1
Oscar Zapata asked on 21 Feb 2010, 04:17 AM
Hello To Everybody:

How Can I get the index of a row and a colum in the gridview???

Please Help me

2 Answers, 1 is accepted

Sort by
0
Accepted
Rossen Hristov
Telerik team
answered on 21 Feb 2010, 07:53 AM
Hello Oscar Zapata,

You can get the index of a data item through the Items property of the grid. For example, to get the index of the currently selected item you should do this:

var selectedIndex = this.radGridView.Items.IndexOf(this.radGridView.SelectedItem);

Row indices should not be used since RadGridView uses virtualization and shows only a small part of the data. In other words a finite set of rows is reused and recycled to show many different data items when you are scrolling up and down. So our advice is to use the Items property. You can also check the Selection online example out.

In case you cannot, could you please elaborate about what is your exact goal and why do you need to know row indices. In other words we will need to know more about what you are trying to achieve so we can come up with a way to show you how.

And for columns you can do something like this:

var columnIndex = this.radGridView.Columns.IndexOf(this.radGridView.CurrentCell.Column);

I hope this helps. If you have any other questions, please do not hesitate to contact us again.

Best wishes,
Ross
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.
0
Oscar Zapata
Top achievements
Rank 1
answered on 22 Feb 2010, 12:24 AM

i have a gridview that i fill with a dataset, that i need is when i click a row of the grid the info that is in the row shows in several textbox
and also the dataset have 5 columns and i need only show 3 in the grid


waht can i do?

thanks for your help!!

Tags
GridView
Asked by
Oscar Zapata
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Oscar Zapata
Top achievements
Rank 1
Share this question
or