getting a child to update after a record add

5 posts, 1 answers
  1. Joe
    Joe avatar
    26 posts
    Member since:
    Feb 2012

    Posted 20 Apr 2015 Link to this post

    Hello;

    I have run out of ideas!

    I have a simple parent/child databound grid.

    The parent has a list of people, the child has a list of stores assigned to them.

    I am wanting so that if I want to assign a new store they can click on "click here to add a new row" then have it work.

    The attached picture should help.

    In "Cust Stop No" they should be able to type in a number, then I want to do some validation to make sure it is a valid store ID.

    If it is, i want to fill in the other columns of data.

    I populate the grid here:

    private void button1_Click(object sender, EventArgs e)
           {
               radGridView1.DataSource = null;
     
               rep_assigned_stop_matrixTableAdapter.FillByStopDetails(first_choice_mainDataSet.rep_assigned_stop_matrix);
     
               GridViewRelation relation = new GridViewRelation(radGridView1.MasterTemplate);
               relation.ChildTemplate = childTemplate;
               relation.RelationName = "repStopRelationship";
               relation.ParentColumnNames.Add("id");
               relation.ChildColumnNames.Add("rep_id");
               radGridView1.Relations.Add(relation);
               radGridView1.DataSource = first_choice_mainDataSet.rep_info;
     
               //radGridView1.AutoGenerateHierarchy = true;
               radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
     
           }

    Then I have tried to catch the cell change event here:

    private void radGridView1_CellValueChanged(object sender, GridViewCellEventArgs e)
         {
     
             IEditableObject editbaleObject = e.Row.DataBoundItem as IEditableObject;
            
     
             DataRowView dataRowView = e.Row.DataBoundItem as DataRowView;
             var rowIndex = e.Row.Index;
             if (rowIndex == -1)
             {
                 radGridView1.Rows[1].Cells["stop_name"].Value = "cityname";
     
             }

     

    I am several hours in and not making any headway....please help!

    Thank you,

     

    Joe

  2. Joe
    Joe avatar
    26 posts
    Member since:
    Feb 2012

    Posted 20 Apr 2015 in reply to Joe Link to this post

    sorry....forgot to attach.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Answer
    Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 21 Apr 2015 Link to this post

    Hi Joe,

    Thank you for writing.

    In this case it would be better to use the UserAddedRow/UserAddingRow events which are fired when the user adds the new row, and you can directly set the cell value if needed:
    void radGridView1_UserAddedRow(object sender, GridViewRowEventArgs e)
    {
        e.Row.Cells[1].Value = "test";  
    }

    In addition, you can use the DefaultValuesNeeded event to add default values. Detailed information is available here: New Row.

    Let me know if you have additional questions.
     
    Regards,
    Dimitar
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  5. Joe
    Joe avatar
    26 posts
    Member since:
    Feb 2012

    Posted 21 Apr 2015 in reply to Dimitar Link to this post

    I read that yesterday and tried it - repeatedly.  It did not work.  Today it works.  I have no idea what I was doing wrong  but it had to be something simple.  Thank you and the documentation was complete and correct.

     end user malfunction.

     Joe

  6. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 21 Apr 2015 Link to this post

    Hello,

    I am glad that everything is working fine on your side now. Do not hesitate to contact us if you have other questions.
     
    Regards,
    Dimitar
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
Back to Top
UI for WinForms is Visual Studio 2017 Ready