views:

20

answers:

3

Hi All,

I have a question. Let's say I had a number of controls which when I click "Add" the same group of controls would display again.

For example my grouped controls would look like this:

First Name: TEXTBOX Last Name: TEXTBOX ADD

When ADD is clicked an additional 2 textboxes appear. So on my page I'd have the following:

First Name: Someones Name Last Name: Someones last name

First Name: TEXTBOX Last Name: TEXTBOX ADD

And so on....

Is there a control (multiview, etc) I could use to do this?

Many thanks in advance,

Jason

+1  A: 

I would recommend using a UserControl. You can create them programmatically.

sgriffinusa
A: 

My favorite control in this scenario is the ListView, which allows you to define templates for regular items and the insert row.

Here is multi-part demo on the list view that will show you how it's done.

http://www.4guysfromrolla.com/articles/010208-1.aspx

The control is especially effective if you are data binding to a data source, which can be a database or .NET objects. Although not directly applicable to the ListView, you may find this resource helpful, as it describes different uses for Data Sources:

http://msdn.microsoft.com/en-us/magazine/cc163862.aspx

kbrimington
A: 

The only way built-in is to use a listview control (or other repeating control) and set it up something like the following: http://mattberseth.com/blog/2008/05/bulk_inserting_data_with_the_l.html

Everytime add is clicked, you have to create a new object from the underlying data source that's blank and rebind the new data source in the listview or other control...

Otherwise, a custom/user control with programmatic creation would get the job done.

Brian