1

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

Jason
  • 11
  • 1
  • 2

3 Answers3

1

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

sgriffinusa
  • 4,203
  • 1
  • 25
  • 26
0

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.

https://web.archive.org/web/20211020150712/https://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
  • 25,142
  • 5
  • 62
  • 74
0

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 Mains
  • 50,520
  • 35
  • 148
  • 257