In one of my project, I came across a formview which which was bound to SQLDataSource. There were 4 procedures inside that SQLDataSource. They were
Now the way functionality called renew functionality. The purpose of renew was to fetch the same record as GetCustomer but instead it fetches it from a different table in a different database. Fortunately all the fields were the same in both stored procedure but what if one SP has different field? Well this actually produces an error.
Assume I am bound my FormView inside codebehind. I used another storedprocedures GetCustomer2 which basically is the same as GetCustomer but it fetches data from different table (it actually is used in a different sense to renew a customer). What happens if I fetch a field that is in GetCustomer2 but not in GetCustomer storedprocedure. It gives an error. Because the comiler tries to find my “new field” in GetCustomer but it is not not there therefore it say, can not find “New Field” in
System.Data.DataRowView’ does not contain a property with the name ‘xxx’.
In this case, I have include a textbox that captures data from the new field and it should technically work but it does not. The way Microsoft implements thing is quite unflexible and rigid.
To solve this problem, you have to include this “new filed” in GetCustomer Stored Procedure, and if it is not in the table itself, you have to add that field to the table too.