By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,127 Members | 1,160 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,127 IT Pros & Developers. It's quick & easy.

Editing static text in ItemTemplate

P: n/a
Hello,

I have a repeater control I am using to display items that are comma
separated. The code looks like this:

<asp:Repeater id="rptSummary" runat="server">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem,
Container.DataItem.Row.Table.Columns(0).ColumnName )%>,
</ItemTemplate>
</asp:Repeater>

The code works exactly as it should. However, for the last item, I would
like to remove the comma at the end of it, since obviously there is no
additional items. This is where I'm getting stuck...

How can I reference my ItemTemplate from code to remove the trailing comma?

It has been suggested to use a SeparatorTemplate to do this, but I still do
not see how to reference the final SeparatorTemplateItem after it is bound to
the data.

Thanks for the help anyone can provide.

- Andre
Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"=?Utf-8?B?QW5kcmUgVmllbnM=?=" <An********@discussions.microsoft.com>
wrote in news:07**********************************@microsof t.com:
How can I reference my ItemTemplate from code to remove the trailing
comma?


An easier way is to place a label in the ItemTemplate. Then on the
OnItemDatabound event, dynamically set the text in the label. I think that
should work better.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 18 '05 #2

P: n/a
> It has been suggested to use a SeparatorTemplate to do this, but I still
do
not see how to reference the final SeparatorTemplateItem after it is bound
to
the data.


Did you bother to even try?

<asp:Repeater id="rptSummary" runat="server">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem,
Container.DataItem.Row.Table.Columns(0).ColumnName )%>
</ItemTemplate>
<SeparatorTemplate>,</SeparatorTemplate>
</asp:Repeater>

SELECT TOP 10 CustomerID FROM customers

outputs...

ALFKI , ANATR , ANTON , AROUT , BERGS , BLAUS , BLONP , BOLID , BONAP ,
BOTTM

Greg
Nov 18 '05 #3

P: n/a
Hello Greg,

My apologies...

I did in fact try the SeparatorTemplate, but I immediately went to debug
mode to try and extract the final separator. I did not realize the separator
itself would not render for the last item.

This works great. Thanks for the help!

- Andre

"Greg Burns" wrote:
It has been suggested to use a SeparatorTemplate to do this, but I still
do
not see how to reference the final SeparatorTemplateItem after it is bound
to
the data.


Did you bother to even try?

<asp:Repeater id="rptSummary" runat="server">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem,
Container.DataItem.Row.Table.Columns(0).ColumnName )%>
</ItemTemplate>
<SeparatorTemplate>,</SeparatorTemplate>
</asp:Repeater>

SELECT TOP 10 CustomerID FROM customers

outputs...

ALFKI , ANATR , ANTON , AROUT , BERGS , BLAUS , BLONP , BOLID , BONAP ,
BOTTM

Greg

Nov 18 '05 #4

P: n/a
I apologize for being curt. No place for that. I should have explained
better.

Greg

"Andre Viens" <An********@discussions.microsoft.com> wrote in message
news:DF**********************************@microsof t.com...
Hello Greg,

My apologies...

I did in fact try the SeparatorTemplate, but I immediately went to debug
mode to try and extract the final separator. I did not realize the
separator
itself would not render for the last item.

This works great. Thanks for the help!

- Andre

"Greg Burns" wrote:
> It has been suggested to use a SeparatorTemplate to do this, but I
> still
> do
> not see how to reference the final SeparatorTemplateItem after it is
> bound
> to
> the data.


Did you bother to even try?

<asp:Repeater id="rptSummary" runat="server">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem,
Container.DataItem.Row.Table.Columns(0).ColumnName )%>
</ItemTemplate>
<SeparatorTemplate>,</SeparatorTemplate>
</asp:Repeater>

SELECT TOP 10 CustomerID FROM customers

outputs...

ALFKI , ANATR , ANTON , AROUT , BERGS , BLAUS , BLONP , BOLID , BONAP ,
BOTTM

Greg

Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.