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

Get selected Row Details

5 Answers 609 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rikin Patel
Top achievements
Rank 1
Rikin Patel asked on 14 Feb 2010, 02:57 AM
How to det selected row Detail i.e i want perform row selected event in which user select row that selected row detail display in textbox so how to get details pls help me

pls help me .............


plsssssssssssssssssssssssssssssssssssss..........
 

as early as possible...

5 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 15 Feb 2010, 08:23 AM
Hi Rikin Patel,

If your detail are shown when a row is clicked you can easily get access to the root element of the RowDetails by using RowDetailsVisibilityChanged event.For example:

    this.gridView.RowDetailsVisibilityChanged += new EventHandler<GridViewRowDetailsEventArgs>(gridView_RowDetailsVisibilityChanged);
  
  
void gridView_RowDetailsVisibilityChanged(object sender, GridViewRowDetailsEventArgs e)
{
    // get the root element of the RowDetails
    var detailsElement = e.DetailsElement;
}

You can also get the same element by using the ItemsContainerGenerator:

private void GetRowDetailsContent()
{
    var selectedRow = (GridViewRow)this.gridView.ItemContainerGenerator.ContainerFromItem(this.gridView.SelectedItem);
    var detailsPresenter = selectedRow.ChildrenOfType<DetailsPresenter>().FirstOrDefault();
  
    // same as e.DetailsElement from gridView_RowDetailsVisibilityChanged
    var detailsContent = detailsPresenter.Content;
}

One you have the detailsPresenter you can actually search for any visual element in the RowDeails template using our ChildrenOfType method.

Hope this helps.


Best wishes,
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
Rikin Patel
Top achievements
Rank 1
answered on 15 Feb 2010, 01:03 PM
thk u milan........

but i am new user of wpf so it is so difficut to understand ......but thk u give me rply....

i got another solution like....

 
DataRow row = (DataRow)radGridView1.SelectedItem;<br> 
 
textBox1.Text = row[0].ToString(); 

i am in 6th sem of mca and make project in WPF(C#)


0
John Giblin
Top achievements
Rank 1
answered on 10 Mar 2011, 09:51 PM
Is there another way to get the value then the index.

It just seems problematic if you add a column then you need to adjust your index for getting the value
0
Er Gopal
Top achievements
Rank 1
answered on 09 Mar 2015, 09:35 AM
Hi Milan,
  .. i had tried your code .. but there is no ....ChildrenOfType...  how i can get .... 
0
Yoan
Telerik team
answered on 09 Mar 2015, 11:15 AM
Hi,

You need a reference to the Telerik.Windows.Controls assembly.

As a side note - you can check the Customize the UI programmatically help article for more information about the use of ParentOfType<> and ChildrenOfType<> extension methods.

Regards,
Yoan
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
GridView
Asked by
Rikin Patel
Top achievements
Rank 1
Answers by
Milan
Telerik team
Rikin Patel
Top achievements
Rank 1
John Giblin
Top achievements
Rank 1
Er Gopal
Top achievements
Rank 1
Yoan
Telerik team
Share this question
or