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

Selected Row Template

1 Answer 206 Views
GridView
This is a migrated thread and some comments may be shown as answers.
mr
Top achievements
Rank 1
mr asked on 28 Aug 2014, 08:18 PM
Gridview with herarchical data.  I need to be able get a value from a column from the selected row in the master template and a different column and row in the child template, how do i add a check to see which template the row selected is on using the gridview click event?

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 02 Sep 2014, 08:49 AM
Hello Mr Smith,

Thank you for writing.

You can determine to which template the clicked cell belongs to via the GridViewCellEventArgs.Row.HierarchyLevel property. Here is a sample code snippet, demonstrating how to get the appropriate template:
private void radGridView1_CellClick(object sender, GridViewCellEventArgs e)
{
    GridViewRowInfo row = e.Row;
    if (e.Row.HierarchyLevel == 0)
    {
        //master template
        MasterGridViewTemplate masterTemplate = e.Row.ViewTemplate as MasterGridViewTemplate;
    }
    else if (e.Row.HierarchyLevel == 1)
    {
        //first level template
        GridViewTemplate template = e.Row.ViewTemplate;
    }
}

I hope this information helps. Should you have further questions, I would be glad to help.

Regards,
Desislava
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
GridView
Asked by
mr
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or