views:

42

answers:

1

When designing an ASP.NET user control my standard way for creating say a details view would be to create a property of the desired type on my page and would set the property in the page load based on the supplied query parameter.

I feel I'm probably doing more work then necessary. If I could encase my view inside a container then I could merely have it databound and thus make everything declarative.

My question is what would be the lightweight container/controls that would be appropriate for databinding a single object?

As a second question, how can I handle invalid query strings with this method?

+2  A: 

I use a <asp:literal .../> as this is very lightweight. I usually also add enableviewstate="false"

Rippo
If you just want to bind one item to the page literal is by far the lightest weight control.
Barry
@Rippo By Item, this could be a complex object with many fields.
Curtis White
@Rippo I am using currently a datalist as the container.
Curtis White
For a complex object a <asp:repeater is pretty lightweight esp if you turn off viewstate.
Rippo