Similar to this question.
An adaptation of an answer on that question..
You can use the Page_Init function in your code behind file to dynamically generate the link and add it to your page header (or body, in your case). An example of that function is below in C#. You would, of course, implement your logic to change the Href value.
protected void Page_Init(object sender, EventArgs e)
{
var link = new HtmlLink();
link.Href = "~/styles/main.css";
link.Attributes.Add("rel", "stylesheet");
link.Attributes.Add("type", "text/css");
Page.Body.Controls.Add(link);
}
Make sure that you put a runat="server" in the body tag so that you can reference the body from the code behind file.
<body runat="server">
</body>