问题
I am generating columns dynamically in my RadGrid, so column count and their names are generated on the fly and so is the datatable that the grid is to be bound to.
Each column either represents an object in my system, or an empty one for user to create a new object. Each object is identified by a unique value property.
I would like to set this value to the column, so, when the grid is edited, I would like to use this value and update the object.
I am open for suggestions. For now I am thinking the options are
- assigning the value to a property in
GridTemplateColumn
(which I dont think is possible) - use a hidden field in header of the column (how do I do it?)
To be more clear, both rows and columns are generated dynamically. I am using DataKeyNames for rows. Wondering how I should be storing unique values for columns!
Any help is appreciated.
Thanks!
回答1:
I doubt if an official Telerik support exists here for this situation. One quirky solution will be to employ a row of hidden fields, one field per column, each storing unique value for the column.
回答2:
You can add the unique value to one of the columns in the datatable and bind this column to grid. Make this column invisible so that it is not visible in the UI, but accessible in the backend.
来源:https://stackoverflow.com/questions/9611453/telerik-radgrid-can-we-save-a-unique-value-against-each-column