2

Say we have this structure in db, with almost none properties. All properties, their name, default value, description and type (string, integer, datetime) are defined in one table (attributeDefinition), and all values are stored in another table.

Cars (Id, Name)

AttributeDefinition(AttributeDefinitionId, Type, Name, Desctiption, MaxValue, ...)

AttributesValues (AttributeDefinitionId, CarId, Value)

Now I want to create a generic editor for the Cars properties.

Question is, how should I implement this? Are there some build in controls that can handle this, are there something similar other have been doing?

Or should I just go like this:

// In MyPropertyEditor.ascx load
// Iterate over all attributes in attributedefinition
//    add TextBox, NumberEditor or DateTimePicker, 
//    give them som good names
// End
//
// In Save, iterate over all controls again, and save back

Am I heading in the right direction?

I was thinking about the datagrid, and how it creates all the columns on the fly. I was hoping I could do something similar?

Thanks for any help

Regards

Larsi

1
  • I don't think there is a control that will do this for you automatically, your best bet will be to use a stored procedure with dynamic sql (Remember to use sp_excecutesql with parameters to prevent sql injection) or you will have to create your own datatable in code, it doesn't look like it will take longer than 10 min or so? Commented May 9, 2011 at 14:30

1 Answer 1

1

Are you talking support inside Visual studio? If you are:

Here are some of the options for handling this: http://msdn.microsoft.com/en-us/magazine/cc164048.aspx In its simplest form, setting up a TypeConverter would get the job done, but if you want a custom UI form, you have to look at creating a custom editor.

If not, but talking a UI for building a web site, you could consider dynamic data as that is what it's meant for - a quick easy way to build UI's for your data and its relationships. There may be some components that you can use even in a web forms project...

HTH.

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

Comments

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.