XmlDataSource, datafile to a variable

Z

Zulander

hi, i am trying to put a session variable in the DataFile of the
XmlDataSource, but for some reason i am getting: Server tags cannot
contain <% ... %> constructs.

<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="<%
Session("UserPath") %> "></asp:XmlDataSource>

I have even tried this:

<asp:XmlDataSource ID="XmlDataSource1" runat="server"
DataFile="<%=Session("UserPath") %> "></asp:XmlDataSource>

any idea ?
 
B

bruce barker \(sqlwork.com\)

server tags can only contain binding expressions, which is interpreted at
runtime. try:

<asp:XmlDataSource ID="XmlDataSource1"
runat="server"
DataFile="<%#Session("UserPath") %>" />

be sure to call the bind method.

-- bruce (sqlwork.com)
 
K

Kevin Jones

One obvious things is the quoting

<asp:XmlDataSource ID="XmlDataSource1" runat="server"
DataFile="<%=Session("UserPath") %> ">
</asp:XmlDataSource>

should be

<asp:XmlDataSource ID="XmlDataSource1" runat="server"
DataFile='<%=Session("UserPath") %> '>
</asp:XmlDataSource>

(notice the single quotes for the datafile), although this gives you
"The server tag is not well formed" errors,

Kevin Jones
 

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,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top