How Can I get the index of a row and a colum in the gridview???
Please Help me
2 Answers, 1 is accepted
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.
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?
Telerik Public Issue Tracking
system and vote to affect the priority of the items.
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