you cant directly access client side code from the server and asp.net is
server side. You can however combine the both by injecting into the page
clientside script.
What you want to do is very simple and you should try swapping css files
server side, that is in asp.net code before you render the page to the
client.
You might want to create a style sheet link reference with an id attribute
and runat="server" in your .aspx page, in html view that is, this way you
can retrieve it in your code behind and pass a seperate css file.
<link id="cssfile1" runat="server" type="text/css" rel="stylesheet" />
and then in your code behind declare an HtmlGenericControl like this :
Public cssfile1 As HtmlGenericControl
Now you can access your stylesheet reference from code and pass a seperate
stylesheet to it everytime you want to change styles.
cssfile1.Attributes.Add("href", Me.ResolveUrl("../css/mainstylesheet.css"))
You can perform this on individual elements by writing inline css whereas to
using a stylesheet or along with the style sheet. This is not a detailed
over view but however it should put you on the right track. Because you are
collecting items from your DB you might want to use inline style sheets
instead. To get what you want working maybe an external stylesheet is not
what your looking for, instead you should add an id attribute to your body
element with runat="server" and declare it in your code behind like you did
with the css file and add an inline style attribute to it, like
style="background-color: #000; color: #ccff66"