I does not work that way. .aspx page is not a file with string contents. It is later compiled to complex class witch later spit it's contents with Response.write.
If you have to add dynamic controls you have to add it as objects to some oth
er control via ControlColection property.
If you want do this with div, add to this div control collection.
If you don't want do this with creation of objects
new AspxGridView();
Do this in markup:
<%if(CreateGrids) %>
<asp:gridview runat="server" xmlns:asp="#unknown">
</asp:gridview>