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

selected row values

3 Answers 119 Views
GridView
This is a migrated thread and some comments may be shown as answers.
dCODE
Top achievements
Rank 1
dCODE asked on 10 Mar 2010, 10:20 AM
Hai

am using the  wpf rad grid view.

when i select the row in the grid view, i need to display selected row values(each cell value in the selected row) in textbox.

how to do this. can u provide some example to how get the values from selected row?

3 Answers, 1 is accepted

Sort by
0
R Shah
Top achievements
Rank 1
answered on 01 Apr 2010, 03:44 PM
Hi,

Did you find this yet ?

Thanks,
Raj
0
Milan
Telerik team
answered on 02 Apr 2010, 07:13 AM
Hello R Shah,

Well, the best approach here would be to use the data item itself:

1.var mySelectedDataItem = (MyDataType)this.playersGrid.SelectedItem;
2.var textForTextBox = mySelectedDataItem.Property1.ToString() + mySelectedDataItem.Property2.ToString();

If that is not convenient you can always get the container for this data item and go thought all cells:

1.var selectedRow = (GridViewRow)this.playersGrid.ItemContainerGenerator.ContainerFromItem(this.playersGrid.SelectedItem);
2.var textForTextBox = "";
3.  
4.foreach (GridViewCell cell in selectedRow.Cells)
5.{
6.    textForTextBox += cell.Value;
7.}

All the best,
Milan
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
phuoc tran ngoc
Top achievements
Rank 1
answered on 05 Oct 2012, 05:14 AM
Hi Milan

I try your way, the code "(MyDataType)this.playersGrid.SelectedItem" is oke
but the "mySelectedDataItem" is allway return null so it didnt work

can you tell me more

thank
Tags
GridView
Asked by
dCODE
Top achievements
Rank 1
Answers by
R Shah
Top achievements
Rank 1
Milan
Telerik team
phuoc tran ngoc
Top achievements
Rank 1
Share this question
or