Working on VS 2010 C# ASP.NET and SQL Server 2008 R2
I'm using a repeater to retrieve data from the SQL server.
I would like to separate 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,
While I don't want the trailing comma and get:
1, 2, 3
What is the best practice to get rid of the trailing comma?
You could try using a separator:
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="ConnectionString">
<ItemTemplate><%# Eval("DataValue").ToString() %></ItemTemplate>
<SeparatorTemplate>, </SeparatorTemplate>
</asp:Repeater>
You may need to be careful with spacing to get it to work properly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With