Display blank controls in repeater

I need to display some text fields and have the ability for the user to "add another line"

I tried the datalist and repeater, but it shows nothing when the controls are empty.

<asp:DataList id="dlIso" runat="server" RepeatColumns="2" RepeatDirection="vertical" > <ItemTemplate> test</ItemTemplate> </asp:DataList> 

therefore, in this case, "test" is now displayed at all.

What is the best way to achieve this?

Thanks!

+4
source share
3 answers

You need to look at InsertItemTemplate .

Sorry, this is for the new ListView . I think the last time I did this, I used FooterTemplate :

http://quickstarts.asp.net/QuickStartv20/aspnet/doc/ctrlref/data/datalist.aspx

I don’t know if this should be done this way, but the footer remains regardless of the current page, so the insert controls are always visible. It works well. You can also simulate command hyperlinks (editing, updating, canceling, etc.), but I can’t remember how to do this.

A good set of articles for ListView can be found here:

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

The linked page is also the one that discusses inserts, but I would suggest reading the lot, from the very beginning.

+1
source

To provide “Add another row” functionality for a repeater or data list, you will have to add another element to any data source to which you are binding the control and call .DataBind ().

If you are attached to the fact that initially it does not contain records, you should use the control with the EmptyDataTemplate parameter (GridView, ListView or DetailsView). For what you do, I would recommend a ListView.

+2
source

The problem is that until you bind your repeater to some datasource , it will not display anything from the itemtemplate element ... so you need to create several datasource for text fields and for each new line add an element to this datasource and bind the repeater again .. the number of elements in your datasource is the number of rows that you will see on the front panel.

0
source

Source: https://habr.com/ru/post/1333492/


All Articles