How do you ... SelectCommand="<%=strSQL%>"

G

googlegroup

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionString:SalesDBConnectionString %>"
SelectCommand="<%=strSQL%>" />

In ASP.NET , how do you assign a dynamic value for the SelectCommand ?
You would think the above should work ?

Thanks...
 
E

Eliyahu Goldin

I think it shouldn't work. A <%= %> block results in evaluating the content
and writing it into the output html stream. It is just a shortcut for
Response.Write(). The value of the SelectCommand attribute has nothing to do
with the client. It is rather used by asp.net on server side.

You can set it dynamically in code-behind.
 
G

googlegroup

Hi,

Thanks for the response.

I still can't figure this out though. How would one do a simple thing
like say select all records where CustomerID=@Customer ? -- or --
CustomerID=<%=CustomerID%>

I get that <%= %> won't work in ASP.NET , so how would you assign the
parameter a value assuming I have it stored as a Dim CustomerID as
String = ""

Thanks...
 
G

googlegroup

Hi,

Thanks for the response.

I still can't figure this out though. How would one do a simple thing
like say select all records where CustomerID=@Customer ? -- or --
CustomerID=<%=CustomerID%>

I get that <%= %> won't work in ASP.NET , so how would you assign the
parameter a value assuming I have it stored as a Dim CustomerID as
String = ""

Thanks...
 
E

Eliyahu Goldin

<%= %> does work in asp.net. It is just doing exactly what it is supposed
to - sending the content of the block to the client's browser. And what you
want is pure server-side functionality.

What can help you is SqlDataSource.SelectParameters Property. Look up the
msdn or google for it.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
 

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,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top