Data Binding in a Repeater

G

Guest

I'm having trouble with my repeater:

I'm binding my Repeater control to an OleDbDataReader object. My ASPX looks
like this:

<asp:Repeater ID="Rptr" runat="server">
<ItemTemplate>
<asp:Label ID="LB" runat="server" Text="" />
<br/>
<%# Eval("TextBody") %>
<br />
<%# Eval("ID") %>
<br />
<%# Eval("Owner") %>
<br />
<%# Eval("CreateDate") %>
</ItemTemplate>
</asp:Repeater>

If I do the above, all works fine. BUT, if I try to set the Text property of
a control such as...
<asp:Label ID="LB" runat="server" Text="<%# Eval("Owner") %>" />

then, I get "The server tag is not well formed" for that Label. Is this
because of the double-quotes that have to be inside the Eval("")?

Also, one other thing: How can I do date formatting for date values coming
back?

Thanks.

Alex
 
S

sloan

Experiment with single and double quotes.
<asp:Label ID="LB" runat="server" Text='<%# Eval("Owner") %>' />

or try a few different permutations.
 
S

Steven Cheng[MSFT]

Hi Alex,

I agree with Sloan's suggestion. VS IDE's html designer won't allow nested
quotes. Therefore as for databinding expression which will need multiple
quotes(nested), we use single quote to replace the outer pair.

Regards,

Steven Cheng
Microsoft MSDN Online Support Lead


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.



Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
S

Steven Cheng[MSFT]

Hey Alex,

Does that suggestion help you resolve the problem? If you still have any
question on this, please feel free to post here.

Regards,

Steven Cheng
Microsoft MSDN Online Support Lead


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.



Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top