In asp.net, I want to select the Top x from a sql server database where x is set programattically in the code behind (cs).
Data binding a string from the code behind to pass to the SelectCommand in the SqlDataSource control doesn't seem to be working.
Is there a way to bind a variable from the code to the SelectCommand of the aspx SqlDataSource, or is there another way?
SqlDataSource. You could do so in your code behind class. Initially, I suggest you try to find out how we can open a sql connection, query a table and consume the result,ADO.NET. Then using a parameter to your query string, you could achieve so fairly easily.