Bruce
Bruce

Reputation: 2203

advice on how to create dynamic controls

My web page will get a set of results from the database and display it to the user. However I am not sure about "number" of results.

Each result will have a panel which contains several controls in itself, an image, several labels, etc.

What is the best way to do this dynamically, eg. create these controls dynamically?

Is it better to use an AJAX control? Should I use Gridview?

Thanks for the help, Behrouz

Upvotes: 1

Views: 448

Answers (3)

Brian Mains
Brian Mains

Reputation: 50728

If the template for each item is the same, use a Repeater. Bind via AJAX if you'd rather bind via web services and save on server-side performance. Then you have to manage everything on the client, which can be tedious, but very performant. Use JQuery to make it easier.

Server-side adding of controls can be a pain, but doable.

HTH.

Upvotes: 0

Hawxby
Hawxby

Reputation: 2804

A repeater is probably the better option for that scenario.

Add all the controls you're likely to need and switch them on and off as needed via the item databound event. http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.repeater.itemdatabound.aspx

Upvotes: 1

ajma
ajma

Reputation: 12206

You need to give us more details about how each result will look like.

I would being by looking at a repeater control. You don't need to know the number of results that get passed to it. You'll be able to specify a template for how each result will look like and the repeater control will take care of rendering one for each result.

Upvotes: 1

Related Questions