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

Determine parent or child in CellEndEdit

2 Answers 73 Views
GridView
This is a migrated thread and some comments may be shown as answers.
gerbrand
Top achievements
Rank 2
gerbrand asked on 07 May 2009, 12:03 PM
How can I determine if I'm editing a parent or a child in the radgrid?

I tried something like this:

private void radgrid_CellEndEdit(object sender, GridViewCellEventArgs e) 
  Console.WriteLine("cell edit"); 
  if (radgrid.Rows[e.RowIndex].ViewTemplate.Parent == null
  { 
    Console.WriteLine(radgrid.Rows[e.RowIndex].Cells[e.ColumnIndex].Value); 
  } 
  else 
  { 
    var template = radgrid.MasterGridViewTemplate.ChildGridViewTemplates[0]; 
    Console.WriteLine(template.Rows[e.RowIndex].Cells[e.ColumnIndex].Value); 
  } 

But I'm keep going in the first part of my if statement.

Thanks


2 Answers, 1 is accepted

Sort by
0
gerbrand
Top achievements
Rank 2
answered on 07 May 2009, 12:13 PM
Okay,

I posted this a little to soon. I found a solution:

private void radgrid_CellEndEdit(object sender, GridViewCellEventArgs e)  
{  
  Console.WriteLine("cell edit");  
  if (radgrid.Rows[e.RowIndex].IsSelected)  
  {  
    Console.WriteLine(radgrid.Rows[e.RowIndex].Cells[e.ColumnIndex].Value);  
  }  
  else  
  {  
    var template = radgrid.MasterGridViewTemplate.ChildGridViewTemplates[0];  
    Console.WriteLine(template.Rows[e.RowIndex].Cells[e.ColumnIndex].Value);  
  }  
}  

But if there is a better solutions just let me know :-)
0
Nick
Telerik team
answered on 07 May 2009, 12:19 PM
Hello gerbrand,

If the parent ViewTemplate is null, you are in the first level of the hierarchy:

ViewTemplate.Parent == null 

I hope this answers your question.

All the best,
Nick
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
gerbrand
Top achievements
Rank 2
Answers by
gerbrand
Top achievements
Rank 2
Nick
Telerik team
Share this question
or