Question

I have a FormView on a ASP.Net Webform along with a ObjectDataSource.

Now, the data that I want to display and allow edit is as follows:

Unique way to access all these properties: Organization ID

Company from DB LDAP Server from/to DB, a KeyValuePair-like table Domain Name from/to DB, a KeyValuePair-like table Use DHCP from/to DB, a KeyValuePair-like table IP Address from/to WMI utility class, no storage in DB Subnet Mask from/to WMI utility class, no storage in DB

So, I need to somehow create an Entity of type... umm... SystemSetting at runtime and feed it to the ObjectDataSource and it'll take care of FormView food-source. Upon Edit, i need to switch to edit mode and upon update, i need to retrieve the values/SystemSetting entity and manually dispatch the value to their respective places.

Now I'm never going to create a new entity. It always display and update. And there is always one entity.

That's theory. Any quick pointers? Thanks.

Was it helpful?

Solution

The simplest solution is to just create a SystemSetting class with public auto properties of the types you mentioned, then make a List<SystemSetting> out of it, and feed that to the ObjectDataSource (if your tables don't have a fixed length, then use a foreach loop to add controls for them on DataBinding event).

On edit, if your tables have a fixed length, then just two-way databind everything and you're all set, you'll automagically get an updated SystemSetting class for your ObjectDataSource update method.

If not, then just handle the updating event yourself (specify a phantom update method for ObjectDataSource and cancel it right then), read input fields one by one (group them under a separate container for each table, or let them share a prefix or suffix for id, so you know where they belong), and dispatch the values to their respective places.

You'll have to provide some more details, or better yet a code sample, for a more complete solution.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top