Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
175
How to display and edit cell value, which has custom object(user defined datatype) for every cell as a data
posted

Hi

Consider i have a student class like following

class Student{

public string Name {get; set;}

public int StudentID {get; set;}

public bool IsActive {get; set;}

}

Now i will be creating a datatable where some of the columns are of Student datatype. When i bind this to grid, i provide user with option to select what value out of these three properties he would like to see in grid, which will be editable too.

I am not able to find a way where i show a single property out of this custom object in a cell, and to update back it in case of modification.

I tried using FormatProvider for cell and able to show property selected by user, but not able to update the property back when edited. Rather i am getting exception related to datatype.

Please guide me to implement this functionality in the grid

Parents
No Data
Reply
  • 469350
    Offline posted

    Hi,

    The grid doesn't know how to edit your custom objects, so there's nothing built-in to the grid to handle a case like this. But there are a couple of approaches you could take here.

    In order to guide you further, though, I need a little clarification on your requirements. When you say the user can choose which of these values he will see in the grid, does that mean the user chooses one for the whole column and every cell in that column displays the same one? Or do you mean that the user might choose to see Name in one row and StudentId in some other row in the same column?

    If it's the latter, then you will need to store that information somewhere - perhaps in another field on the Student class itself or in another column in the grid.

Children