FeliceM
FeliceM

Reputation: 4209

Comment a line of code in a SqlDataSource in ASP.NET markup

I normally use

<%-- Comment/or line of code --%>

to comment out a line of code in asp.net mark up. Sometimes I just select the line that I like to comment out and press

ctrl+(k, c)

to automatically comment out the line or

ctrl+(k, u)

to uncomment the line. For some reason, I cannot comment out a line of code in a SqlDataSource this way. Something like this gives an error:

.......
<%--SelectCommand="SELECT * FROM [myTable] ORDER BY [Code]"--%>
SelectCommand="SELECT * FROM [anotherTable] ORDER BY [Code]"
.........

I wonder why I am getting an error in such cases? Is there a way to comment out a line of code in a SqlDataSource in the markup?

Upvotes: 1

Views: 396

Answers (1)

Oggy
Oggy

Reputation: 1666

As Michael said, such comments are not allowed. However you can use SQL comments within the property value, for example:

SelectCommand="/*SELECT * FROM [myTable] ORDER BY [Code]*/SELECT * FROM [anotherTable] ORDER BY [Code]"

Upvotes: 3

Related Questions