Hi!
I have this DataTable that has a varying set of columns except for a sequence number.
| Sequence | Value | Tax | Duty | Total |
Any number of columns should be accepted with unique column names.
To display that table, I need to use an ObjectDataSource mapped to a presenter class with a Select method.
class Presenter {
[DataObjectMethod(DataObjectMethodType.Select)]
public DataView GetDutyAndTax() { ... }
}
The ObjectDataSource is then bound to a GridView with AutoGenerateColumns set to true. Sequence is the data key.
So far, that works for selecting the table. The problem comes when I need to update the table. The ObjectDataSource keeps nagging me to have an update method with the exact same parameters with that of the columns in the table.
public void EditDutyAndTax(string Value, string Tax, string Duty, string original_Sequence) { ... }
But I can not create a method like that because I don't know the set of columns needed.
I tried using a method with variable parameter list but it doesn't want to use it.
public void EditDutyAndTax(params object[] values) { ... }
On idea I have now is to create a set of update methods like this in Presenter:
public void EditDutyAndTax(string value1, string original_Sequence) { ... }
public void EditDutyAndTax(string value1, string value2, string original_Sequence) { ... }
public void EditDutyAndTax(string value1, string value2, string value3, string original_Sequence) { ... }
//an so on...
But I neither think that's gonna get through code review nor like the idea.
The other idea I have is to create a dynamic method and attach that (if possible) to the Presenter class or wherever at runtime, but I'm not really sure if that would work.
So if you guys have any solution, please help. Thanks so much!
Carlos