How to get rid of the final comma using ASP.NET repeater?

Work on VS 2010 C # ASP.NET and SQL Server 2008 R2

I am using a repeater to retrieve data from an SQL server.

I would like to highlight the values ​​with a comma.

my code is:

<asp:Repeater ID="Repeater1" runat="server" DataSourceID="ConnectionString"> <ItemTemplate> <%# Eval("DataValue").ToString() %>, </ItemTemplate> </asp:Repeater> 

I get:

 1, 2, 3, 

So far I do not want the trailing comma and get:

 1, 2, 3 

What is the best practice to get rid of the final comma?

+6
source share
1 answer

You can try using a delimiter:

 <asp:Repeater ID="Repeater1" runat="server" DataSourceID="ConnectionString"> <ItemTemplate><%# Eval("DataValue").ToString() %></ItemTemplate> <SeparatorTemplate>, </SeparatorTemplate> </asp:Repeater> 

You may need to be careful at intervals to make it work correctly.

+13
source

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


All Articles