5

I've been getting parser error with message The server tag is not well formed for the following line.

                    <asp:Repeater runat="server" DataSource="<%# ((MultilistField)((Item)Container.DataItem).Fields["Tags"]).GetItems() %>">
                    <ItemTemplate>
                        <sc:FieldRenderer ID="FieldRenderer1" runat="server" FieldName="Tag name" Item="<%# Container.DataItem %>"/>
                    </ItemTemplate>
                    <SeparatorTemplate>
                        /
                    </SeparatorTemplate>
                </asp:Repeater>

The syntax looks fine, but one thing I'm not sure about is whether you can use the ".Field["tags"] element in there.

I've tried looking it up, but couldn't find a similar problem. I'm hoping someone provide me with some insight to why the parser is complaining about this line.

Thanks

1
  • 1
    trying using single quotes for DataSource instead of double quotes.
    – Jeremy
    Jun 14, 2012 at 18:09

4 Answers 4

13

What comes into my mind right now is to use a single-quoted string instead:

<asp:Repeater runat="server" DataSource='<%# ((MultilistField)((Item)Container.DataItem).Fields["Tags"]).GetItems() %>' >
3
  • You guys are magical! Can't believe I haven't tried that. I try to changed the inside double quote to single, but that didn't work. Thank you all a bunch!
    – Jun Zheng
    Jun 14, 2012 at 18:13
  • @STi88 - That's because single quotes are not valid string delimiters in C#/VB.NET.
    – Oded
    Jun 14, 2012 at 18:16
  • @Oded Yep you are correct, I was just desperate for a solution... Can't believe the thought of the outside single quote slip pass me.
    – Jun Zheng
    Jun 14, 2012 at 22:49
3

You have double quotes within the attribute. This confuses the parser - it can't tell where the attribute ends.

Wrap the attribute in single quotes to fix it:

DataSource='<%# ((MultilistField)((Item)Container.DataItem).Fields["Tags"]).GetItems() %>'
1

try ' instead of " it might work

else try binding from code behind

<asp:Repeater runat="server" DataSource='<%# ((MultilistField)((Item)Container.DataItem).Fields["Tags"]).GetItems() %>' >
0

Do you have a closing tag? i.e.

</asp:Repeater>

Otherwise you are missing the / at the end of your tag declaration.

<asp:Repeater runat="server" DataSource="<%# ((MultilistField)((Item)Container.DataItem).Fields["Tags"]).GetItems() %>" />
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.