Determine parent or child in CellEndEdit

3 posts, 0 answers
  1. gerbrand
    gerbrand avatar
    78 posts
    Member since:
    Mar 2009

    Posted 07 May 2009 Link to this post

    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. gerbrand
    gerbrand avatar
    78 posts
    Member since:
    Mar 2009

    Posted 07 May 2009 Link to this post

    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 :-)
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Nick
    Admin
    Nick avatar
    767 posts

    Posted 07 May 2009 Link to this post

    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.
Back to Top