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

how to Get Selection Item Value

6 Answers 131 Views
GridView
This is a migrated thread and some comments may be shown as answers.
davood ramezani
Top achievements
Rank 1
davood ramezani asked on 08 Nov 2010, 08:53 AM
hi
how can i Get Value of Cell from Selected Item in RadGridView .

6 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 08 Nov 2010, 08:59 AM
Hi davood ramezani,

Once you get the SelectedItem, you may work with its corresponding properties. For example, if the items are of type Player that has properties - Name, Country, Number, you may do the following:

var player = this.playersGrid.SelectedItem as Player;
  player.Country = "newCountry";
  player.Name = "newName";
  player.Number = 1;

 

All the best,
Maya
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
davood ramezani
Top achievements
Rank 1
answered on 09 Nov 2010, 07:37 AM
hi
radGridview Selected Item is
{ PersonelCode = 780099, FName = Ali, LName = Ahmadi, NationalNo = 491528841, Id = d7e6373d-0765-45dd-a59a-f71bca10babf }
And My Class Is:
public class SelectedStaff
  {
      public Guid Id { get; set; }
      public string FName { get; set; }
      public string LName { get; set; }
      public string PersonelCode { get; set; }
      public string NationalNo { get; set; }
  }
and Code for UnBox is:
SelectedStaff selectedStaff = searchStaff_grid.SelectedItem as SelectedStaff; 

 

 

 

but out of service

 

 

 

 

 

result is null
0
Maya
Telerik team
answered on 09 Nov 2010, 10:00 AM
Hi davood ramezani,

In order to provide an appropriate solution, I would need a bit more details. Do you select any item before executing the code SelectedStaff selectedStaff = grid.SelectedItem as SelectedStaff ? When do you try to invoke the selected item ?
 

All the best,
Maya
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
davood ramezani
Top achievements
Rank 1
answered on 10 Nov 2010, 06:22 AM
hi
tank you for answer.
Yes, I select item before executing the code SelectedStaff selectedStaff = grid.SelectedItem as SelectedStaff

GridView Bind  to a class higher than the number of its field .
0
Maya
Telerik team
answered on 10 Nov 2010, 09:05 AM
Hello davood ramezani,

I am sending you a sample demonstrating how to work with the values of the selected item. Let me know in case your scenario is not corresponding to the one in the application. Feel free to change it in the way you need and share more details in case of any differences.
 

All the best,
Maya
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
davood ramezani
Top achievements
Rank 1
answered on 11 Nov 2010, 05:50 AM
Tnank you For Example I Do it.
Tags
GridView
Asked by
davood ramezani
Top achievements
Rank 1
Answers by
Maya
Telerik team
davood ramezani
Top achievements
Rank 1
Share this question
or