0

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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Oh goodie! I did already created the SystemSetting class and SystemSettingList class. The SystemSettingList is inheriting a List<SystemSetting>. Although, there always will be one SystemSetting in the SystemSettingList but I guess for the sake of proper data bindings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.