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
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.
Hi Mike,
I am working with Aatish on the same problem.
When user choose any value, all the cells in the Grid should show the same value. Lets take user selects name, then the entire Grid should show Names.
Need your guidance.
Thanks,Rajesh