views:

80

answers:

2

For instance, I have a SqlDataSource that loads a list of items. On my form, I've got 3 dropdown boxes that both should contain that same list of values, and then the user can select a different value for each and save.

By hooking up each dropdown list to the same SqlDataSource, the database gets hit three times - one for each object that lists it as a datasource. If I remove the "automatic" links that you find in the SmartTag interface, I'd still have to have code-behind that would call DataBind on each of the comboboxes, which would again cause three calls to the Database.

I guess I could pull back the values into a list of strings that I store in the ViewState, but is there a better way?

A: 

You should let go of your reliance on direct databindings for form elements and just build a list or array that is replicated or cloned. Then bind to your separate lists to the form elements and "write code" to handle what you want it to do against your datasource.

mugafuga
Hey, thanks for the answer with an extra dose of attitude - you obviously are a coding god. The question was is there a built in way that Microsoft has to handle this, that's all. You answered the question with what I already said "in" the question....
Sam Schutte
+2  A: 

Why don't you enable caching for your datasources?

Keltex
Cool - that seems to have fixed it. I thought that it was already set, but I guess it wasn't! Thanks!
Sam Schutte