c# - Generic version of this function -
in quest of reviewing old code came across this:
private void initializerow(gridviewrowinfo destrow, gridviewrowinfo sourcerow) { destrow.cells["image"].value = sourcerow.cells["image"].value; destrow.cells["name"].value = sourcerow.cells["name"].value; destrow.cells["country"].value = sourcerow.cells["country"].value; destrow.cells["price"].value = sourcerow.cells["price"].value; }
i want rewrite in more generic, not have write every columns name string. assuming same not in same order can't use index. :
private void initializerow(gridviewrowinfo destrow, gridviewrowinfo sourcerow) { foreach (gridviewcellinfocollection csource in sourcerow.cells) { destrow.cells.oftype<csource.gettype()> = sourcerow.cells.oftype<csource.gettype()> ; } }
assuming telerik grid, can this:
private void initializerow(gridviewrowinfo destrow, gridviewrowinfo sourcerow) { foreach (gridviewcellinfo csource in sourcerow.cells) { destrow.cells[csource.columninfo.name].value = csource.value; } }
Comments
Post a Comment