Cell updated from code - value not appearing on Grid

2 posts, 0 answers
  1. Churamani
    Churamani avatar
    1 posts
    Member since:
    Sep 2013

    Posted 02 Mar 2014 Link to this post

    I am trying to update multiple rows of cells at once. Suppose the user selects 5 rows to be edited. The user updates the values only in the 1st row and then click on a button (Edit Selected Rows). The other selected rows should have the same value as the first row. 

    But the values are not visible on the UI after the button is selected. However, when I double click on any cell in the other selected rows, the updated values then appears. How to make it appear by click of the button so that I need not have to double click on every cell to check if the values are updated

    private void radButton_Edit_Selected_Click(object sender,  RoutedEventArgs e)
    {
    var x = grid_name.rdvRates.SelectedItems;
    int counter = 1;
    string score =string.Empty;
    foreach (object y in x)
    {
    if (counter == 1)
    {
    score = SomeMethod.GetPropertyValue(y, "SCORE");
    counter = counter + 1;
    }
    else
    {
    SomeMethod.SetPropertyValue(y, "SCORE", score);
    }
    }
    }

    public static void SomeMethod.SetPropertyValue(object obj, string name, object value)
            {
    Type type = obj.GetType();
    if (type != null)
    {
    PropertyInfo prop = type.GetProperty(name);
    if (prop != null)
    {
    prop.SetValue(obj, value, null);
    }
    }
            } 
  2. Yoan
    Admin
    Yoan avatar
    1066 posts

    Posted 06 Mar 2014 Link to this post

    Hi Churamani,

    You can achieve your goal by manipulating the value of each selected item in GridView's RowEditEnded event. I have prepared a sample project showing you the approach. You can find it attached.

    Regards,
    Yoan
    Telerik

    DevCraft Q1'14 is here! Join the free online conference to see how this release solves your top-5 .NET challenges. Reserve your seat now!

  3. DevCraft banner
Back to Top