I have a asp.net page I’m writing and I’m perplexed by this problem. I have 3 DetailViews that I bind with LINQ. The binding works great. Now, I have a Skin file that I want to use to layout the DVs, and it looks like this.
<asp:DetailsView SkinID='blogViews' runat='server' Width='100%' CssClass='post' AutoGenerateRows='False' GridLines='None' FooterStyle-CssClass='comments' FooterStyle-Height='50px'> <Fields> <asp:BoundField DataField='blog_title' ShowHeader='False' ItemStyle-CssClass='title' ItemStyle-Font-Size='X-Large'/> <asp:BoundField DataField='blog_content' HtmlEncode='False' ShowHeader='False' ItemStyle-CssClass='entry' /> </Fields>
Now the problem is, I need to add a templateField to display some data, and I need it between the title and content fields. By using a template field, I need to do an:
Eval('blog_datetime')
and a few others. Unfortunately, the Skin file doesn’t allow code blocks. I can’t add the template field to the aspx page itself, because it puts the templateField at the bottom of the DetailsView. I guess what I am asking is:
How can I work around the fact that I can’t put a code block in a skin file?
I am wondering if you would be better off creating a custom control for laying out these details views?
Skin files are for modifying styles more than behavior and binding.
A custom control would allow you to do all of this and get the benefit of shared layout for the three data views.